why does [XMLHttpReequest] Message come?
I am calling below javascript/ajax page method from code behind, then why does [XMLHttpReequest] Message come?
var options = {
type: "POST",
url: "Test.aspx/SendMessage",
data: "{'toMailAddress':'" + val + "','rno':'" + rno+ "', 'nonrno':'" + nonrno+ "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
var val1 = response.d;
alert(val1);
if (val1 == "1") {
// Below code is used to close the window, if message has been sent to the user suces开发者_运维百科sfully.
var windowObj = window.self;
windowObj.opener = window.self;
windowObj.close();
}
},
error: function (result) {
alert("Error in " + result);
}
};
$.ajax(options);
I expect the message you are in fact seeing is "Error in XMLHttpRequest". This is what you would see if an error occurred during the call, because you have the wrong arguments for the error call back.
The method signature for the jQuery ajax error callback is:
error(XMLHttpRequest, textStatus, errorThrown)
So your error alert is being passed the XMLHttpRequest
object, which is probably not what you meant to do. The code implicitly calls the toString()
method on the XMLHttpRequest
which will return "[object XMLHttpRequest]"
.
If that message isn't coming from the error callback, then there must be another bit of code somewhere passing the XMLHttpRequest
object to alert()
. I suggest you set a break point after your own alert()
and single step through to see where the other alert()
is.
精彩评论