Using $.getJSON to perform cross domain request problem.
Posted
by
Ahmed
on Stack Overflow
See other posts from Stack Overflow
or by Ahmed
Published on 2011-02-20T07:03:41Z
Indexed on
2011/02/20
7:25 UTC
Read the original article
Hit count: 239
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);
}
});
© Stack Overflow or respective owner