In my code (see below), I make an AJAX call. Firebug tells me "Error: Bad http response code: 0" and the page reloads. If I step through the code, it works, i.e. no errors, and then the page reloads. The server-side code is returning only headers and Apache is returning a 200 return code.
1. Why is my page reloading?
2. Any suggestions on tracking down this heisenbug?
function sendFNDdata(pressedBtn) {
var myresponse;
var vargetFNDdata = {
url: "cgi-bin/PortSim/getFNDdata.pl",
handleAs: "text",
content: { value: pressedBtn },
timeout: 5000, // Time in milliseconds
form:dojo.byId("fndParms"),
load: function(response, ioArgs) {
myresponse = response;
alert('YES!');
dojo.byId("cargo").innerHTML = response;
return response;
},
error: function(response, ioArgs) {
myresponse = response;
console.error("HTTP status code: ", ioArgs.xhr.status);
return response;
}
};
dojo.xhrGet(vargetFNDdata);
return myresponse;
};which is called by
Output Files

If this is in IE, I've heard
If this is in IE, I've heard of "response 0" errors when you try to do an ajax call as part of a user click action, but you do not stop the event and the default action executes. If IE thinks it is a link (even a javascript link) it will cancel any inflight requests (like the ajax request) and try to follow the link.
So if that is the case, make sure to cancel the event (like using dojo.stopEvent(evt)).
I should have mentioned...
my environment is Firefox 2.0 on CentOS 5.0. I have seen differences in the GUI behavior between FF on Linux, FF on Windows and IE but I didn't think to see if this works differently.
WTH, it can't hurt, eh? [goes back to coding...] Hmm, I put dojo.stopEvent(evt) in with no difference, but how does the system know what evt refers to? I never declared evt. That should have thrown an error, no?
Hmm. OK, not sure then. On
onclick='sendFNDdata(event, "Output Files")'
value='Output Files'>Output Files
</button>
dojo.stopEvent(evt);
....
}
Sonuva...
On this page (http://markos.gaivo.net/blog/?p=109) I came across the suggestion (down in the comments) to put 'onSubmit="return false";' on the form and it worked!
And it turns out you're right as well! I changed my code as you suggested and it works!
Am I the first person in here to ever combine XHR And forms?!
I think this *really* needs to go into the docs!
Thanks for the help.