I have a jQuery ajax call that is working fine in IE, but continually errors in Chrome and Firefox. I have similar ajax calls elsewhere in my application and they work fine in all browsers but for some reason this one doesn’t.
First off, is there something obvious that I am doing here that would break in browsers other than IE, and second and just as important, is there a way to get something meaningful out of the error: function (e) {} block?
$.ajax({
type: "POST",
url: "http://localhost:52350/FabRouting/Webservice/FinalizeFileStream.asmx/FinalizeFileStreamDoc",
data: JSON.stringify({ DocID: docID, FileSize: file.size }),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
if (data.d.length == 0) {
//error
$("[id$=txtResult]").val("error 0");
}
else {
$("[id$=txtResult]").val(data.d[0].Result);
}
},
error: function (e) {
//error
$("[id$=txtResult]").val("error");
}
});
It ended up not being my code or the browsers (well kinda) after all, just my error.
I kept researching and read something where someone was having trouble with a cross-domain ajax call giving errors. I am not trying to do that, however I did have two Visual Studio web servers spun up for some reason. I looked and I was calling the webservice with a hard coded url (http://localhost:52350/FabRouting/Webservice…….)for the time being and I was using the new url (http://localhost:59986/FabRouting/Tes…..) to access the page.
This was working fine in IE for some reason, but when I was trying it in Chrome or Firefox it was not working. I changed where I was accessing the page and I got a good return value from the ajax call.
I would still like to know how to get a more meaningful error and @dtryan has me part way there. If anyone can help me figure that out I will mark theirs as the answer and not this answer.
EDIT:
I later found that I was in fact able to get error messages the way I was trying before and the way @dtryan was suggesting as well. The problem was that for some reason since this was throwing an error because it was trying to go cross-domain, but I wasn’t able to capture that error.
I have since had out of memory errors, etc and those I am able to capture and see just fine. I think this just was a perfect storm causing the errors not to be visible. If anyone has any way to capture these errors it would be good to know.