I made a webservice for me it’s works fine in local computer.
Now i deploy my project on iis and want to use that service from service deployed url
service works fine on that url
but when i use that url in json not working. Here is my code it works fine
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "WebService.asmx/getlinqdata",
data: '{}',
dataType: "json",
success: function (jsonText) {
var myObject = eval(jsonText.d);
for (var i = 0; i < myObject.length; i++) {
$('#main').append('<p>' + myObject[i].Id + '</p>');
$('#main').append('<p>' + myObject[i].Name + '</p>');
$('#main').append('<p>' + myObject[i].Day + '</p>');
$('#main').append('<p>' + myObject[i].Month + '</p>');
$('#main').append('<p>' + myObject[i].Year + '</p>');
$('#main').append('<br/>');
}
},
error: function (msg) {
alert("Error: " + msg.d);
}
});
this works fine for me but when i use deployed webservice url this url is
http://localhost:1234/WebService.asmx/getlinqdata
getlinqdata is my function to call
thax
You will likely go from one domain (URL) to another (that is cross domain), you cannot use JSON as it is, but instead have to rely on JSONP.
you will check out below references. Hopes its work for u
http://www.codeproject.com/KB/aspnet/Cross_Domain_Call.aspx
http://www.wictorwilen.se/Post/SharePoint-Online-and-External-Data-using-JSONP.aspx