Note that there are some explanatory texts on larger screens.

plurals
  1. POUse success() or complete() in AJAX call
    primarykey
    data
    text
    <p>I want to understand the AJAX call below, in terms of the <code>complete()</code> method;</p> <p>When I replace <code>complete()</code> with <code>success()</code>, I get an empty <em>responseText</em> just as with the AJAX <code>error()</code> method.</p> <p>On the other hand, when I leave the <code>complete()</code> method there as it is, everything works as expected.</p> <p>Is it that <code>success()</code> returns earlier than <code>complete()</code>?</p> <pre><code>$("#formnaw").submit(function() { var fnc = invoerFnc.attr("value"); var vnaam = invoerVnaam.attr("value"); var anaam = invoerAnaam.attr("value"); var str1 = invoerStr1.attr("value"); var nr1 = invoerNr1.attr("value"); var pc1 = invoerPc1.attr("value"); var pl1 = invoerPl1.attr("value"); var tel1 = invoerTel1.attr("value"); var mob1 = invoerMob1.attr("value"); var em1 = invoerEm1.attr("value"); var goknop = $("#formnaw &gt; .instelling_go"); //we deactiveren de submit knop tijdens het verzenden goknop.attr({ disabled: true }); goknop.blur(); //stuur de post variabelen naar livetabs.php $.ajax({ type: "POST", url: "registraties/instellingenact.php", data: "actie=wijzignaw&amp;vnaam=" + vnaam + "&amp;anaam=" + anaam + "&amp;functie=" + fnc + "&amp;straat=" + str1 + "&amp;nr=" + nr1 + "&amp;postcode=" + pc1 + "&amp;plaats=" + pl1 + "&amp;tel=" + tel1 + "&amp;mob=" + mob1 + "&amp;email=" + em1, timeout: 5000, success: function(data, textStatus) { alert('bij success'); //doe iets } //EINDE success , error: function(XMLHttpRequest, textStatus, errorThrown) { if (textStatus == 'timeout') { //doe iets } else if (textStatus == 'error') { //doe iets } //her-activeer de zend knop goknop.attr({ disabled: false }); } //EINDE error , complete: function(data) { updatelijst.append(data.responseText + "&lt;br&gt;"); if (data.responseText.indexOf("Fout") != -1) { $('#formnaw').find('td.foutnr1').prepend(data.responseText); } else { updatelijst.animate({ opacity: 'show' }, 1000, function() {}); } //her-activeer de zend knop goknop.attr({ disabled: false }); } //EINDE complete }); //EINDE ajax //we stoppen het standaard gedrag van een submit, zodat de pagina niet wordt vernieuwd. return false; }); </code></pre>
    singulars
    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.
    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