Reputation: 13
When i am trying to access the services in the same solution the webservice is returning me the result. But when i upload this webservice and trying to access then is giving the error.
var _postData = '{lat:"42.28684519999999",lang:"-83.05254932"}';
$.ajax({
url: 'http://geo.xyz.com/Service.asmx/GetGeoLocationListByLatLang',
data: _postData,
type: "POST",
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function (data) {
alert(data.d);
// $.each(data, function (i, item) {
// alert(i);
// });
//Result(data);
// alert(data.d);
// var obj = $.parseJSON(data.d);
// alert(obj);
},
error: function (request, status, error) {
alert(request.responseText);
alert(error);
alert(status);
}
});
Upvotes: 1
Views: 200
Reputation: 1038780
You are violating the same origin policy restriction that's built-in browsers and which prevents you from sending cross domain AJAX requests. Here's a nice guide which covers different possible workarounds. But since you need to use POST your choices are very limited at this stage. I guess that a server side proxy on your domain serving as a bridge and delegating the call to the remote domain would be the best solution.
Upvotes: 1