Note that there are some explanatory texts on larger screens.

plurals
  1. POModifying form data before submission
    primarykey
    data
    text
    <p>I'm using jQuery in conjunction with the <a href="http://malsup.com/jquery/form/" rel="nofollow noreferrer">form plugin</a> and I'd like to intercept the form data before submission and make changes. </p> <p>The form plugin has a property called beforeSubmit that should do this, but I seem to be having trouble getting the function I specify to run.</p> <p>Here's the markup for the form (some style details omitted):</p> <pre><code>&lt;form id="form1"&gt; &lt;fieldset id="login"&gt; &lt;legend&gt;Please Log In&lt;/legend&gt; &lt;label for="txtLogin"&gt;Login&lt;/label&gt; &lt;input id="txtLogin" type="text" /&gt; &lt;label for="txtPassword"&gt;Password&lt;/label&gt; &lt;input id="txtPassword" type="password" /&gt; &lt;button type="submit" id="btnLogin"&gt;Log In&lt;/button&gt; &lt;/fieldset&gt; &lt;/form&gt; </code></pre> <p>And here's the javascript that I have so far:</p> <pre><code>$(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); }); </code></pre> <p>(log.info() is from the <a href="http://www.gscottolson.com/blackbirdjs/" rel="nofollow noreferrer">Blackbird</a> debugger library I'm using)</p> <p>When I click the submit button, rather than the POST verb I specified it uses a GET instead, and nothing is logged from my beforeSubmit function. It seems that the ajaxForm plugin is not being applied to the form at all, but I don't see why. Can anybody help with this?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload