Hi everyone. I'm having trouble using the $ajax() jQuery function. The same happens to me in three diferent Ajax calls in two different projects. I'll post sample code of one of them, since I can't really find a pattern common to all three (but different than the other Ajax calls in my code that work as expected):
function ajaxSendForm() { data = { command: 'save', // a bunch of parameter names and values taken from the form }; $.ajax({ url: "ajaxOrderForm.aspx", type: "POST", dataType: "xml", cache: false, data: data, error: function(req, err, obj) { alert ("Error in Ajax call: " + err + " - " + req.status); }, success: function (xml) { // Process return data } }); } This produces an alert with the text: "Error in Ajax call: - 0", that is, empty error message and a value of 0 for the status member of the HttpXMLRequest object. If I check the server logs I can see that the server code is being executed. This only happens in Firefox (version 2.0.0.11, Firebug 1.05 installed), not Internet Explorer; and if I execute the Ajax call again, it does work as expected. I have introduced this patch that seems to do the trick: error: function(req, err, obj) { // _sffirst is a global variable initialized to true; if (_sffirst && (req.status == 0) ) { _sffirst = false; ajaxSendForm(); } else { alert ("Error in Ajax call: " + err + " - " + req.status); } }, This is somewhat acceptable for data recovery, but not for data storage - I don't want every order to be recorded twice! Has anyone else encountered this problem? Is it an error in jQuery, in the native HttpXMLRequest object, or is it something I'm doing wrong? Thanks in advance.