You need to sign in to do that
Don't have an account?

Problem with sforce.apex.execute
Hi,
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;
}
}
{
WebService static String getDefault(String Text)
{
return 'My Company ' + Text;
}
}
Then, I try to use this code in a SControl:
<html>
<head>
<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>
<script>
function demo()
{
var strResult = sforce.apex.execute('WSPage', 'getDefault', {Text:'Testing...'});
document.getElementById('Header').innerHTML = strResult;
}
</script>
</head>
<body onload=demo()>
<div id='Header'>
</div>
</body>
</html>
<head>
<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>
<script>
function demo()
{
var strResult = sforce.apex.execute('WSPage', 'getDefault', {Text:'Testing...'});
document.getElementById('Header').innerHTML = strResult;
}
</script>
</head>
<body onload=demo()>
<div id='Header'>
</div>
</body>
</html>
I'm getting a JavaScript error on my tab. Does anybody know what the problem could be?
Thanks
My Company Testing...
i am using firefox, also tested this on IE7
what browser are you running?
also,
what is the javascript error that you see?
you may want to modify this line to include quotes, like so:
<body onload="demo();" >