+ Start a Discussion

Problem with sforce.apex.execute

I'm just starting with Apex, and I'm having problems with my first example:
I have the following code:
global class WSPage
    WebService static String getDefault(String Text)
        return 'My Company ' + Text;
Then, I try to use this code in a SControl:
<script type="text/javascript" src="/js/functions.js"></script>
<script type="text/javascript" src="/soap/ajax/10.0/connection.js"></script>
<script type="text/javascript" src="/soap/ajax/10.0/apex.js"></script>
function demo()
    var strResult = sforce.apex.execute('WSPage', 'getDefault', {Text:'Testing...'});
    document.getElementById('Header').innerHTML = strResult;
<body onload=demo()>
<div id='Header'>
I'm getting a JavaScript error on my tab.  Does anybody know what the problem could be?
Ron HessRon Hess
this code is correct, i pasted it into my test org and it runs correctly, returning a tab that contains

My Company Testing...

i am using firefox, also tested this on IE7

what browser are you running?
what is the javascript error that you see?

Ron HessRon Hess
wild guess,
you may want to modify this line to include quotes, like so:

<body onload="demo();" >
I was testing this with an old developer account.  I just created a new developer account and pasted the code and it works properly.
Any ideas on the difference between old salesforce accounts and new ones?
Diego Arteaga
Ron HessRon Hess
old may not have Apex code turned on