Thinkphp ajax submission problems

Source: Internet
Author: User
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 ();
}
}

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.