function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Accessing Apex WebService from jQuery

I need to know if it's possible to retrieve some data from SFDC via jQuery.  I created a sample apex webservice to do this.  Then the webservice will be accessed from a 3rd party website via jQuery.  Problem is when it executes the processResponse() function, an exception is thrown because the xmlHttpRequest.responseXML is NULL.  What seems to be the problem?  =(


Here's the code of the webservice:  

global class TARetrieveArticlesWebService {
     WebService static String GetArticles()
          In_Depth__c sampleData = [SELECT Name FROM In_Depth__c LIMIT 1];
          return sampleData.Name;


And here's the code that I placed in the 3rd party site: 

     <script src='' type='text/javascript'/>


<script type='text/javascript'>
var soapMessage = "<soap:Envelope xmlns:soap='' xmlns:xsd='' xmlns:xsi=''><soap:Body><methodCall>GetArticles</methodCall></soap:Body></soap:Envelope>";


     url: "",
     type: "POST",
     dataType: "xml",
     data: soapMessage,
     complete: processResponse,
     contentType: "text/xml; charset=\"utf-8\""


function processResponse(xmlHttpRequest, status)
          var name = $(this).find('response').text();

Henry AkpalaHenry Akpala

Don't you need to pass the sessionId or authentication parameter?