javascript - jQuery Ajax call not processing .done -


i have been beating head against desk, , not sure why javascript/jquery (1.71) not completing it's tasks before doing else.

i calling function strictly jquery ajax call. function performs ajax portion, .done not being processed before leaves function , returns original calling function.

if through code, stripped out non-essential code, left call. call processajax function. trace through it, function called, ajax process performed, , returns dups function , alert ('stopping here') triggered before done section processed.

what's going on?!?

here code:

function dups(){     $('#dupchecker').val(2);     if ($('#spdegree').length){     // logic here      }      else if ($('#meetingid').length){     // logic here                 }      else {     // logic here                 }      processajax(user, actdate, meetid, degree, act);      alert('stopping here');      return 0;  };  function processajax(a,b,c,d,e){      $.ajax({         url: "desubmit_testdups.cfm",         cache:false,         method: "post",         data: {id:a, adate:b, meet:c, degree:d, act:e},         datatype: "html"     })                .done(function( html ) {         myresult = parseint($.trim( html ));         alert ('myresult= '+ myresult);         if (myresult == 0){             $('#submitbtn').prop("disabled",false);             $('#errormsg').css("visibility","hidden");             $('#dupchecker').val(1);         }         else {             $('#submitbtn').prop("disabled",true);             $('#errormsg').css("visibility","visible");             $('#dupchecker').val(0);         }     })      .fail(function( jqxhr, textstatus ) {     alert( "request failed: " + textstatus );     });  }; 

function dups(){     $('#dupchecker').val(2);     if ($('#spdegree').length){     // logic here      }      else if ($('#meetingid').length){     // logic here                 }      else {     // logic here                 }      processajax(user, actdate, meetid, degree, act, function(resp){          alert('stopping here');     });        return 0;  };  function processajax(a,b,c,d,e, callback){      $.ajax({         url: "desubmit_testdups.cfm",         cache:false,         method: "post",         data: {id:a, adate:b, meet:c, degree:d, act:e},         datatype: "html"     })                .done(function( html ) {         myresult = parseint($.trim( html ));         alert ('myresult= '+ myresult);         if (myresult == 0){             $('#submitbtn').prop("disabled",false);             $('#errormsg').css("visibility","hidden");             $('#dupchecker').val(1);         }         else {             $('#submitbtn').prop("disabled",true);             $('#errormsg').css("visibility","visible");             $('#dupchecker').val(0);         }         callback();     })      .fail(function( jqxhr, textstatus ) {         alert( "request failed: " + textstatus );         callback();     });  }; 

hope helps you. can use callback make synchronous. can pass ajax response callback.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -