Discuz Uchome ajaxpost tips_PHP tutorial

WBOY
Release: 2016-07-21 15:32:58
Original
908 people have browsed it

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.

www.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();...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template