ajax - jQuery call remote web service -


i'm trying call web service using jquery , read lot of examples, unfortunately can't make work.

i'm trying call web service exercise : http://www.w3schools.com/webservices/tempconvert.asmx?op=celsiustofahrenheit

this code below, no matter do, receive errors 500 (internal server error) or 400 bad request.

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 = '<celsius>5</celsius>';  $.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");                   } }); } 

i'm not sure how should pass parameters ...

can describe problem , make example work ?

thanks lot.

try this

function getit(){   var divtobeworkedon = "#ajaxplaceholder";      var webmethod = "http://www.w3schools.com/webservices/tempconvert.asmx/celsiustofahrenheit?callback=?";    var parameters = {'celsius':'5'};    $.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");                   }   }); } 

Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -