For example, the default submit button operates like this: onclick="ajaxpost('formid')"; and so on, we can do this first. .
onclick="$('__formid').innerText='';ajaxpost('formid');checkPostResult();";
The meaning is actually very simple. First clear the div content where the ajaxpost prompt information is located. Then submit. Finally, judge based on the return value. .
Copy code The code is as follows:
function checkPostResult(){
var cid = setInterval(function(){
if( $('__formid').innerText == 'success'){
alert('Submission successful');
location.href='xxxxx.php';
clearInterval(cid) ;
}
},1000);
}
This process is also very simple. Why setInterval and clearInterval are used? The main reason is that ajax is an asynchronous operation. If setInterval is not used method, then when the ajaxpost ends, the prompt information has not actually been appended to the ID where the prompt information is located, so use the setInterval method to first delay and then loop to process and finally end the prompt. . .
clearInterval is not used correctly, but I can’t think of a better one in a short time. This is a temporary solution first.
http://www.bkjia.com/PHPjc/322679.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/322679.htmlTechArticleFor example, the default submit button operates like this: onclick="ajaxpost('formid')"; and so on, we can This first. . onclick="$('__formid').innerText='';ajaxpost('formid');checkPostResult();...