title: JQuery AJAX Consume SOAP Web Service
body: <p>I have been experimenting and trying to learn JQuery, using AJAX to consume a SOAP web service I had written some time ago.  Below is the code I am using:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      var webServiceURL = 'http://local_server_name/baanws/dataservice.asmx?op=GetAllCategoryFamilies';
      var soapMessage = '&lt;soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"&gt;&lt;soap12:Body&gt;&lt;GetAllCategoryFamilies xmlns="http://tempuri.org/" /&gt;&lt;/soap12:Body&gt;&lt;/soap12:Envelope';
  
      function CallService()
      {
          $.ajax({
              url: webServiceURL, 
              type: "POST",
              dataType: "xml", 
              data: soapMessage, 
              contentType: "text/xml; charset=\"utf-8\"",
              success: OnSuccess, 
              error: OnError
          });
  
          return false;
      }
  
      function OnSuccess(data, status)
      {
          alert(data.d);
      }
  
      function OnError(request, status, error)
      {
          alert('error');
      }
  
      $(document).ready(function() {
          jQuery.support.cors = true;
      });
  &lt;/script&gt;
  
  &lt;form method="post" action=""&gt;
      &lt;div&gt;
          &lt;input type="button" value="Call Web Service" onclick="CallService(); return false;" /&gt;
      &lt;/div&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Currently, the method being called in the web service returns an array of category families that contain a category code and a category description.  Since the method returns XML, I set the ajax query accordingly.  However, when I run the app,  I get an 'error' alert box - I am sure what would be causing the problem.  I know the web service works, it's called several hundred times a day by other .NET web apps that I've written.  </p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p>Thanks,</p>