I have written API in Cloud service using web role. This api is working fine (cheked via postman, .net Webclient, etc). But it does not working only via Ajax call in client side.
var car = { minlat: '11', minlong: '45', maxlat: '-44', maxlong:'130', locationlevel: 'city' };
$.ajax({
async: true,
type: "POST",
contentType:"application/x-www-form-urlencoded; charset=utf-8",
url: "url",
data: JSON.stringify(car),
// dataType: "json",
success: function (data) {
var obj = data.d;
if (obj == 'true') {
}
},
error: function (result) {
alert("Error");
}
});
Can anyone explain that cross domain will affect ajax call? I am calling API of Cloud service. And testing this in local host server.
contentTypeshould beapplication/jsonand also usedataType: "json"