I use jQuery in combination with a form plugin and I would like to intercept the form data before submitting and make changes.
The form plugin has a property called beforeSubmit that should do this, but I seem to be having trouble getting the function I will specify to run.
Here's the markup for the form (some style details are omitted):
<form id="form1"> <fieldset id="login"> <legend>Please Log In</legend> <label for="txtLogin">Login</label> <input id="txtLogin" type="text" /> <label for="txtPassword">Password</label> <input id="txtPassword" type="password" /> <button type="submit" id="btnLogin">Log In</button> </fieldset> </form>
And here is the javascript that I have so far:
$(document).ready(function() { var options = { method: 'post', url: 'Login.aspx', beforeSubmit: function(formData, form, options) { $.each(formData, function() { log.info(this.value); }); return true; } }; $('form#form1').ajaxForm(options); });
(log.info () from the Blackbird debugger library I'm using)
When I click the Submit button, instead of specifying POST, I indicated that it uses GET instead, and nothing is written to my beforeSubmit function. The ajaxForm plugin doesn't seem to apply to the form at all, but I don't understand why. Can anyone help with this?
source share