Brain-Dead Moment of the day or… is IE9 trying to display your ajax result and double-submitting your forms?
July 31, 2011 1 Comment
A non-perl post but something that bugged me for a few hours today until:
I had an ajax-handled form that was working fine for ages, but when run under IE9 it would display the result of the ajax request, or try to download the ajax (when the content type was set to application/json).
Sadly, we didn’t have IE9 in our testing setup for this bit of code (our Windows machine was XP Pro, and that cannot have IE9 it seemed), so we got this as feedback from my co-worker when he got a new machine recently. (The shame is large).
Once I got the test machine updated and running IE9, it was clear the form was being double-submitted, and the result of the second submission was being displayed. hmmmm…
On that one form (oops) I had forgotten to set onsubmit=”return false;” in the form. The Ajax handler was returning false, and also stopping the event, but for some reason IE9 was submitting that form.
Adding onsubmit=”return false;” solved my problem (and that’s our S.O.P. that was missed for this form). Hope that helps!