getContext() that, if happy, would then fire off the actual worker asynchronously (ajax).
That form’s button was firing the form immediately rather than waiting for the results of the check(s). Adding a
return false; to the button’s setup fixed it. Here’s how:
<button onclick="getContext();return false;">do stuff!</button>
Why does this matter?
The moment the form’s do stuff! button is clicked, the form is submitted. This means that the form was submitted at the same time the function was called, generating a response to the browser – the Status Code 0 – before the function could process anything. By setting
return false; on the function call, the form submission is cancelled in the browser but the function call continues to process the request.