您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

Yii框架异步请求

Yii框架异步请求

@hakre您提供的内容不会减少用户等待响应的时间。

我找到了最好的解决方案:yii的runactions扩展

这是扩展程序,可让您从控制器后台操作运行。有几种使用方法。对于我来说,最好的方法

public function actionTimeConsumingProcess()
{
    if (ERunActions::runBackground())
    {
       //do all the stuff that should work in background
       mail->send()
    }
    else
    {
        //this code will be executed immediately
        //echo 'Time-consuming process has been started'
        //user->setFlash ...render ... redirect,
    }
  //User information
  echo "Submit Success!"
}

并且它的工作但没有ajax请求,当我发出ajax请求时,由于某种原因它不起作用。所以我用了:

                         ERunActions::httpPOST($this->createAbsoluteUrl('Form/Submit'), array('to'=>'mail@domain.com', 'subject'=>'This is the subject'));

它的工作很棒,但不是理想的解决方案。

其他 2022/1/1 18:16:06 有544人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶