Brain-Dead Moment of the day or… is IE9 trying to display your ajax result and double-submitting your forms?

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!

Post to Twitter Post to Digg Post to Facebook Send Gmail Post to LinkedIn Post to Reddit Post to StumbleUpon

About Tom
I work in a healthcare technology startup. These days, I attempt to code in Perl, and this blog is about the Wild Perl we write, startup life, and many other things.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>