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

Calling Apex in Ajax?
Hey-
I am trying to write a simple method to call an APEX script from JavaScript...to learn how it functions (so my code does not do anything). I feel like I have followed the instructions...but I keep getting this error:
Code:
{faultcode:'soapenv:Client', faultstring:'No service available for class 'webserviceTest'', }
Here is my class:
Code:
global class webserviceTest { webservice static String getAccounts(Id userId) { String Name = 'TEST'; return Name; } }
Here is my s-control:
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <script type="text/javascript" src="/js/functions.js"></script> <script src="/soap/ajax/11.0/connection.js"></script> <script src="/soap/ajax/11.0/apex.js"></script> <script type="text/javascript"> function init() { try { var accts = sforce.apex.execute("webserviceTest","getAccounts",{userId:"{!$User.Id}"}); } catch (e) { document.getElementById('test').innerHTML = e.toString(); } alert(accts); } </script> </head> <body onload="init()" id='test'> </body> </html>
Am I missing something? Thanks in advance for any help!
Message Edited by tinman44 on 06-02-2008 12:21 PM
Thanks for this valuable info!!