Heim  >  Artikel  >  Backend-Entwicklung  >  Thinkphp的ajax提交的有关问题

Thinkphp的ajax提交的有关问题

WBOY
WBOYOriginal
2016-06-13 11:21:29934Durchsuche

Thinkphp的ajax提交的问题
在做ajax提交的过程中遇到两个问题。
1:在使用ajax提交到一个action的method中之后,我又使用$this->upload()的方式调用了另一个方法。在这个方法中有需要返回错误或者成功的信息,所以使用了【return...】返回一个值,可是这个值就直接返回给前台了。。我想的是应该从提交到的method中返回到前台。。

2:使用$this->isAjax()判断返回错误,我是使用thinkajax提交的表单,所以在form下添加了一个可是还是判断不成功。。

请大家不吝赐教。。

PHP,ajax
------解决方案--------------------
  if (!$upload->upload()){
                  return $this->error($upload->getErrorMsg());              }else{
                  return $upload->getUploadFileInfo();
                            }
     }

改成:
  if (!$upload->upload()){
                  $this->assign("jumpUrl","你要跳转的method地址");
                   $this->error($upload->getErrorMsg());              }else{
                  return $upload->getUploadFileInfo();
                            }
     }
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn