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 ();...