Using $.getJSON to perform cross domain request problem.
- by Ahmed
I'm using the following code to make cross domain request using $.getJSON, request completed but with errors, I cannot exactly detect what is the thrown error.
Based on callback param of request value I route it to a certain method which retrieves required JSON data.
$.getJSON("http://wthsrvr:45452/Handler.ashx/?Callback=DocumentReadStatus",
{
userID: vuserID,
documentID: vdocumentID,
format: "json"
},
function(result) {
if (result.readStatus == '1') {
alert("ACCEPTED");
}
else if (result.readStatus == '0') {
alert("NOT ACCEPTED");
}
else {
alert(result.readStatus);
}
});
FYI: while development of this locally, everything worked fine, but after solution deployment to server and trying to do the same, I got that problem.
Also, I tried the same functionality with web service, I got the same problem while calling web service from server.
I'm using ajaxSetup to detect thrown errors.
$.ajaxSetup({ "error": function(XMLHttpRequest, textStatus, errorThrown) {
alert("textStatus: " + textStatus);
alert("errorThrown: " + errorThrown);
alert("responseText: " + XMLHttpRequest.responseText);
}
});