Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy is my JS code running in an apparent loop?
    primarykey
    data
    text
    <p>I have the following code:</p> <h2>JS</h2> <pre><code>&lt;script type="text/javascript"&gt; $(function(){ $('#fgotpwfield').hide(); $('#login_submit').click(function() { $('#form_result').fadeOut('fast'); $('#myccrxlogin input').removeAttr('disabled'); $('#myccrxlogin').submit(); }); if ($("#myccrxlogin").length &gt; 0) { $("#myccrxlogin").validate({ rules: { email: { required: true, email: true }, password: 'required' }, messages: { email: { required: 'Your email address is required.', email: 'Please enter a valid email address.'}, password: 'Your password is required.' }, submitHandler: function(form) { $('#myccrxlogin input').attr('disabled','true'); $('#login_submit').fadeOut('fast'); $('#forgotpw').fadeOut('fast'); $('body').append('&lt;div id="page_load"&gt;&lt;/div&gt;'); var email = $("#email").val(); var pw = $("#password").val(); var data = 'email=' + email + '&amp;password=' + pw; $.ajax({ url: "hidden url", type: "POST", data: data, cache: false, success: function (html) { $('#page_load').remove(); if(html == 'OK') { alert(html); } else { //$("#password").val(''); $("#form_result").html(html); $('#form_result').fadeIn('slow'); $('#myccrxlogin input').removeAttr('disabled'); $('#login_submit').fadeIn('slow'); $('#forgotpw').fadeIn('slow'); } } }); } /*close submit handler */ }); }; }); &lt;/script&gt; </code></pre> <h2>HTML</h2> <pre><code>&lt;div id="form_result" style="margin:10px; display:none;" class="field-submit-error"&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt; &lt;div id="loginformfield"&gt; &lt;p style="font-size:24px; font-weight:bold; font-family:Arial, Helvetica, sans-serif; color:#f93;"&gt;Login&lt;/p&gt; &lt;form class="loginform" id="myccrxlogin" method="post" target="_parent"&gt; &lt;p&gt; &lt;input name="email" type="text" id="email" tabindex="1" /&gt; &lt;label for="email"&gt;E-mail&lt;/label&gt;&lt;/p&gt; &lt;p&gt;&lt;input name="password" type="password" class="text large required" id="password" tabindex="2" /&gt; &lt;label for="password"&gt;Password&lt;/label&gt;&lt;/p&gt; &lt;div class="loading"&gt;&lt;/div&gt; &lt;p&gt;&lt;a href="#" id="forgotpw"&gt;I forgot my password&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a class="readmore" href="#" id="login_submit" style="margin-bottom:0.5em;" tabindex="3"&gt;Login!&lt;/a&gt;&lt;/p&gt; &lt;/form&gt; &lt;/div&gt; </code></pre> <p>A person enters their email and password, the file is first validated then run through an ajax call successfully. The ajax PHP page echo's either an error or 'OK'. I know the code gets to 'OK' because the alert(html) is triggered but it runs infinitely. Not sure why?</p> <h2>update</h2> <p>I believe I <strong>might</strong> be running into the recursion issue described here: <a href="http://docs.jquery.com/Plugins/Validation#General_Guidelines" rel="nofollow">http://docs.jquery.com/Plugins/Validation#General_Guidelines</a> although I am not sure it applies.</p>
    singulars
    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.
 

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