Thinkphp encountered two problems during ajax submission. 1: After ajax is used to submit a method to an action, I used $ this-& gt; upload () to call another method. In this method, an error or success message needs to be returned. Therefore, a value is returned using [return...], but this value is directly returned to the foreground .. What I think is the question of the ajax submission from the submitted metho Thinkphp
Two problems are encountered during ajax submission.
1: After ajax is used to submit a method to an action, I used $ this-> upload () to call another method. In this method, an error or success message needs to be returned. Therefore, a value is returned using [return...], but this value is directly returned to the foreground .. What I want is to return to the foreground from the submitted method ..
2: Use $ this-> isAjax () to identify the returned error. I submitted the form using thinkajax, so I added However, it still fails to be judged ..
Please kindly advise ..
PHP and ajax
------ Solution --------------------
If (! $ Upload-> upload ()){
Return $ this-> error ($ upload-> getErrorMsg ();} else {
Return $ upload-> getUploadFileInfo ();
}
}
Changed:
If (! $ Upload-> upload ()){
$ This-> assign ("jumpUrl", "method address you want to jump ");
$ This-> error ($ upload-> getErrorMsg ();} else {
Return $ upload-> getUploadFileInfo ();
}
}