jQuery Forms Plugin: Unsupported Property or Method Error

Another minor headache with the jQuery Forms plugin and WordPress.  I’m trying to do this WordPress Plugin right, using the standard WP way of Ajax where you target “wp-admin/admin-ajax.php” and hook into the Ajax features with a hidden field named “action” from your form that tells WP what the hook name you’re trying to call.  Here’s what the hook definition in your plugin looks like:

add_action('wp_ajax_photosmash', array($this,'loadAJAX') );
add_action('wp_ajax_nopriv_photosmash', array($this,'loadAJAX') );

So, your form needs a hidden element like:

<input type='hidden' name='action' value='photosmash' />

To top it off, I’m using a File upload, which invokes the iFrame upload functionality in the jQuery Forms plugin. This all works fine in Chrome, but in FireFox and IE8 on Windows (not sure about FF on Mac), the action field blows up the jQuery Forms ajaxForm() function. You get a message:

Line: 54
Error: Object doesn't support this property or method

Maybe I’m doing something wrong, but it looks like either WP or jQuery.Forms.js needs to tweak their code (WP would need to look for something other than the ‘action’ field, or Forms would need to use a different method name).

After hours and hours of trying to get this to work, I’ve decided to abandon the standard WP Ajax method of hooking into “add_action(‘wp_ajax…’, ‘…’);” in this case, and am now just pointing my script to an ajax startup file that bootstraps WP.

I even tried adding the “action” parameter via javascript in the jquery.forms.js plugin’s beforeSubmit function. No joy 🙁

If anyone has another idea, I’d be glad to hear/try it. I really wanted to do this the right way, but I don’t think it’s in the cards this time. There comes a time when you stop banging into the brick wall and go around it instead.

Byron

, ,

3 Responses to jQuery Forms Plugin: Unsupported Property or Method Error

  1. Arnold June 4, 2011 at 9:20 am #

    Have you tried replacing $ with jQuery? WP jquery runs in no conflict mode and that should get rid of the errors.

  2. Sap_Blog June 7, 2011 at 12:08 pm #

    Why “Sap” label here?

    • byron June 7, 2011 at 2:12 pm #

      Good question! Fixed…thanks!

Powered by WordPress. Designed by Woo Themes