Note that there are some explanatory texts on larger screens.

plurals
  1. PODelay between AJAX call and form submit
    primarykey
    data
    text
    <p>The following code snippet explains a situation:-</p> <pre><code>function submitHandler(form) { return x(form) &amp;&amp; y(form); } </code></pre> <p>x is an external function which validates the form. It returns false if form is not validated and if validated it submits the form. </p> <p>y is a function, which should be called only if form is validated. It makes an AJAX call, JSONP type. JSONP ajax calls can only be async.</p> <p>Y internally submits the form after getting the response. y will always return false.</p> <p>I'm not sure what x does exactly but I can confirm y is called but AJAX call inside it is cancelled.</p> <p>When I create a break-point and run in firebug debug mode, the AJAX call is successful. Thus, I think creating a delay can solve the problem.</p> <p>Is there any way to create a delay after the AJAX call?</p> <p><strong>Update:</strong></p> <p>The function y:-</p> <pre><code>function y(jsonStr) { jQuery.ajax({ url: url, contentType: 'application/json', dataType: 'jsonp', data: { jsonInfo: jsonStr, jsonpCallback: 'submitForm' } }); } </code></pre> <p><strong>update 2:</strong></p> <p>The function x (edited)</p> <pre><code>function x(form) { clearError(); var submitButton = null; var allowSubmit = true; // Some code for ( var i = 0; i &lt; form.elements.length; i++) { var fld = form.elements[i]; if (!validateField(fld)) { allowSubmit = false; } } if (allowSubmit) { if (!pageSubmitted) { pageSubmitted = true; // some code form.submit(); if (submitButton != null) { submitButton.disabled = true; submitButton.value = getPleaseWaitMessage(); } } else { allowSubmit = false; } } // Some code return allowSubmit; } </code></pre>
    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.
 

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