title: jQuery Ajax request in Sharepoint 2007 (SOAP)
body: <p>I have the following web service:</p>
  
  <pre><code>SOAP 1.1
  
  The following is a sample SOAP 1.1 request and response. The placeholders shown need to be replaced with actual values.
  
  POST /_vti_bin/QuickLinks.asmx HTTP/1.1
  Host: myintracomm-design.ec.europa.eu
  Content-Type: text/xml; charset=utf-8
  Content-Length: length
  SOAPAction: "http://ec.europa.eu/GetSuggestions"
  
  &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;
    &lt;soap:Body&gt;
      &lt;GetSuggestions xmlns="http://ec.europa.eu/"&gt;
        &lt;prefixText&gt;string&lt;/prefixText&gt;
        &lt;count&gt;int&lt;/count&gt;
      &lt;/GetSuggestions&gt;
    &lt;/soap:Body&gt;
  &lt;/soap:Envelope&gt;
  
  HTTP/1.1 200 OK
  Content-Type: text/xml; charset=utf-8
  Content-Length: length
  
  &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;
    &lt;soap:Body&gt;
      &lt;GetSuggestionsResponse xmlns="http://ec.europa.eu/"&gt;
        &lt;GetSuggestionsResult&gt;
          &lt;string&gt;string&lt;/string&gt;
          &lt;string&gt;string&lt;/string&gt;
        &lt;/GetSuggestionsResult&gt;
      &lt;/GetSuggestionsResponse&gt;
    &lt;/soap:Body&gt;
  &lt;/soap:Envelope&gt;
  </code></pre>
  
  <p>Which I locate by navigating to a url like:</p>
  
  <p><a href="http://www.bla.eu/_vti_bin/QuickLinks.asmx?op=GetSuggestions" rel="nofollow noreferrer">http://www.bla.eu/_vti_bin/QuickLinks.asmx?op=GetSuggestions</a></p>
  
  <p>I tried to make an Ajax request to fetch the content lying behind this, by using this code:</p>
  
  <pre><code>var productServiceUrl = 'http://myintracomm-design.ec.europa.eu/_vti_bin/QuickLinks.asmx?op=GetSuggestions';
  
  function LoadData() {
      var soapEnv = 
      '&lt;soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt; \
             &lt;soap:Body&gt; \
                &lt;GetSuggestions xmlns="http://ec.europa.eu/"&gt; \
                &lt;prefixText&gt;sys&lt;/prefixTest&gt; \
                &lt;count&gt;10&lt;/count&gt; \
                &lt;/GetSuggestions&gt; \
               &lt;/soap:Body&gt; \
          &lt;/soap:Envelope&gt;';
  
      $jQuery.ajax({
          url: productServiceUrl,
          type: "POST",
          dataType: "xml",
          data: soapEnv,
          complete: OnLinksFetched,
          contentType: "text/xml; charset=\"utf-8\""
      });
  }
  
  function OnLinksFetched(xmlHttpRequest, status)
      {
       $jQuery(xmlHttpRequest.responseXML)
          .find('GetSuggestionsResult')
          .each(function() {
         var name = $jQuery(this).find('Name').text();
         $jQuery("#links").append(name);
       });}
  </code></pre>
  
  <p>and I added an simple onclick event to a link (just for testing purposes). Unfortunately, I get a bad request error.<img src="https://i.stack.imgur.com/4bvUf.png" alt="here is the error in action">
  I tried many combinations of the soap request (as I have no experience in SOAP) but with no success. Decided to post here after 5 days of effort. Thanks in advance for any help.</p>