douyou4819 2015-08-09 00:05
浏览 456

如何在laravel中使用make :: view或redirect来打开一个新的选项卡/窗口?

I have a page with a button having ajax function. After the button is clicked, I would like the page to return to a new page with the variable needed to pass into the page. the variable and everything works fine but the page wouldn't go into a new page. It wouldn't even show in the same page only in console.

What should I do to make the view / direct / redirect to show up in a new tab / window?

EDIT the whole code is quite long so let me try cutting them down.

in my controller where I have a function and after function runs it easily returns this

return View::make('date', array('longContents' => $longStringContainAllContents));

in my original parent window I have a button and simple code like this which uses ajax to go into the controller with the correct routes

      $.ajax({
          method: "post",
          url: "/report",
          success: function(data){
          }
      });

in my date.blade.php I just simply have this.

<div class='text-block-single'>{{ $longContents  }}</div>

then when I click the button, the page doesn't reload. and in console I can see the ajax is running properly and when I see the responds in console which is good and in the console where I can see the HTML which is good too.

  • 写回答

1条回答 默认 最新

  • dousou3027 2015-08-09 00:19
    关注

    You can't accomplish this with ajax because it's asynchronous call and ajax calls returns ajax responses. So for this staff and without seeing any code , i recommend to do this in a normal request and run redirection from your controller or router. And if you want to open a new browser tab you must do it with JavaScript without involving any ajax and send the data thought in a normal get request to your controller or routes,

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体