jQuery Form failure

I’ve used the jQuery form plugin a few times before, but today I ran into an error I’d not seen before that took a few minutes to solve. I started out by searching Google, but couldn’t find the solution, so I’m writing it here in the hope of helping others in my unfortunate situation. 🙂

The error was caused in jquery-1.3.2.min.js and went like this: (E || "").replace is not a function

I upgraded to jQuery 1.4.2 uncompressed and found that the same thing happened, but with a more helpful message: return (text || "").replace( rtrim, "" ); is not a function

I opened up jquery.form.js and did a quick search for ‘trim‘ and it only returned one result: var url = $.trim(this.attr('action'));

This is when I realised that my form had no action attribute, which is bad HTML even though fairly consistent browser behaviour is to submit to the current page.

Once I added the attribute to my form it all worked as expected. I’ve written a patch for the jquery.form.js file that I’ll submit to the developer in a couple of minutes. 🙂