weixin_33725722 2017-06-28 23:28 采纳率: 0%
浏览 143


In my blade I use an ajax call to call a route. In my controller I am returning a different view. However, the view does not change. I am wondering if I need to change the view differently because I am using an ajax call that needs a return of success or not.

Here is my ajax code in my blade

               var text = $('#cv').val();
                    headers: {
                        'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                    type: 'POST',
                    url: "/widget/measurableresults",
                    data: {
                        text: text,
                    success: function (msg) {
                    error: function (msg) {

Here is my route

Route::post('/widget/measurableresults', 'WidgetController@measurableresults');

Here the method in my controller

 public function measurableresults()
        $text = Input::get('text');
        Log::debug( $text );
        return view('results.measurableresults');

The Log::debug prints out the value of $text and the ajax call returns success. However, the view does not change to results.measurableresults. What am I missing?

  • 写回答

1条回答 默认 最新

  • 狐狸.fox 2017-06-28 23:35

    Try and remove the line Log::debug( $text );, it's probably blocking the return statement to execute


    You seem not to understand how things work in ajax and php communication, the success code you're receiving doesn't mean ajax returned the expected value, if you log the ajax response, you'll get the html text in the view you're returning, it's not that ajax will magically change the view for you.

    Please make more research in regards to this.




    • ¥15 Qt播放10路ffmpeg 视频流
    • ¥15 如何利用闲置机械硬盘变现
    • ¥15 信号处理中的凸优化问题
    • ¥15 arm虚拟机无法和物理机互通
    • ¥15 Android导航条遮盖异常
    • ¥15 计算机网络技术基础问题
    • ¥15 设置mac系统只能访问指定网站
    • ¥15 西门子博途 s7 1200控制三台步进电机
    • ¥15 基于非参数的方向距离函数求污染物影子价格(有偿)
    • ¥15 vue+element 生成table