DiscuzUchomeajaxpost tips _ PHP Tutorial

Source: Internet
Author: User
DiscuzUchomeajaxpost tips. For example, if the default submit button is like this: onclickajaxpost (formid);, we can do this first .. Onclick $ (_ formid ). innerText; ajaxpost (formid); checkPostResult (); for example, if the default submit button is like this: onclick = "ajaxpost ('formid ')";, we can do this first ..
Onclick = "$ ('_ formid'). innerText =''; ajaxpost ('formid '); checkPostResult ();";
The meaning is actually very simple. first, clear the p content of the ajaxpost prompt information. Then submit. Finally, it is determined based on the return value ..

The code is as follows:


Function checkPostResult (){
Var cid = setInterval (function (){
If ($ ('_ formid'). innerText = 'success '){
Alert ('submitted successfully ');
Location. href = 'xxxxx. php ';
ClearInterval (cid );
}
},1000 );
}


This processing is also very simple. why is setInterval and clearInterval used? it is mainly because ajax is an asynchronous operation. if the setInterval method is not used, at the end of ajaxpost, in fact, the prompt information has not been appended to the ID of the prompt information, so the setInterval method is used to delay and then process the prompt cyclically before closing...

ClearInterval is not correct, but it cannot be better in a short time. Solve the problem temporarily.

Pipeline "ajaxpost ('formid ')"; and so on. we can do this first .. Onclick = "$ ('_ formid'). innerText =''; ajaxpost ('formid '); checkPostResult ();...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.