title: jQuery call remote web service
body: <p>I'm trying to call web service using jQuery and I read a lot of examples, but unfortunately I can't make it work.</p>
  
  <p>I'm trying to call this web service for my exercise : <a href="http://www.w3schools.com/webservices/tempconvert.asmx?op=CelsiusToFahrenheit" rel="nofollow">http://www.w3schools.com/webservices/tempconvert.asmx?op=CelsiusToFahrenheit</a></p>
  
  <p>This is my code below, but no matter what I do, I receive errors 500 (Internal Server Error) or 400 Bad request.</p>
  
  <pre><code>function GetIt(){
  var divToBeWorkedOn = "#AjaxPlaceHolder";
  var webMethod = "http://www.w3schools.com/webservices/tempconvert.asmx/CelsiusToFahrenheit?callback=?";
  var parameters = 'POST /webservices/tempconvert.asmx/CelsiusToFahrenheit HTTP/1.1 Host: www.w3schools.com Content-Type: application/x-www-form-urlencoded Content-Length: 9 Celsius=5';
  //var parameters = 'Celsius=5';
  //var parameters = '&lt;Celsius&gt;5&lt;/Celsius&gt;';
  
  $.ajax({
      type: "POST",
      url: webMethod,
      data: parameters,
      contentType: "text/xml; charset=utf-8",//"application/json; charset=utf-8",
      dataType: "xml", //"json"
      success: function(msg) {    
          $(divToBeWorkedOn).html(msg.d);
      },
      error: function(e){
          $(divToBeWorkedOn).html("Unavailable");              
      }
  });
  }
  </code></pre>
  
  <p>I'm not sure how I should pass the parameters ...</p>
  
  <p>Can anybody describe where is the problem and make this example work ?</p>
  
  <p>Thanks a lot.</p>