I have the following code where i construct json data and send to the webservice ,my datatype will be json and response from the webservice will be in xml format does this logic work out or do i need to stick to any one particular datatype either json or xml.
var keyword2 = “{\”keyword1\”:\”” + keyword1 + “\”,\”streetname\”:\”” + address1 + “\”,\”lat\”:\”” + lat + “\”,\”lng\”:\”” + lng + “\”,\”radius\”:\”” + radius + “\”}”;
//keyword2 will be my json constructed data ,will it be same in case of xml construction
$.ajax({
type: “POST”,
async: false,
url: “/blkseek2/JsonWebService.asmx/GetList”,
datatype:”json”,
data:keyword2,
contentType: “application/xml; charset=utf-8”,
failure: function(XMLHttpRequest, textStatus, errorThrown)
{ ajaxError(XMLHttpRequest,textStatus, errorThrown); },
success: function(xml)
{ ajaxFinish(xml); }
// success: ajaxCallSucceed,
// dataType: “xml”,
// failure: ajaxCallFailed
});
});
See here: http://api.jquery.com/jQuery.ajax/
contentType and dataTypeString are the 2 u need.
Like this: