首页 > 解决方案 > 如何将值多个参数从 jquery 传递到 laravel 控制器?

问题描述

我的代码有问题,我不明白如何将多个参数从 jquery 发送到控制器

这是我的路线

Route::get('/listcdix/{id}/detail/{asnumber}', 
['as' => 'remindHelper', 'uses' => 'ListcdixController@detail']);

下面是我的jQuery

otable.on("click", ".btnview",
      function () {
      var custcode = otable.rows($(this).closest("tr")).data()[0].CustCode;
      var asnumber = otable.rows($(this).closest("tr")).data()[0].ASNumber;
  window.location = "{{route('remindHelper',['id'=>"+custcode+",'asnumber'=>"+asnumber+"])}}";
          });

但是当我单击此按钮时无法获得价值custcode并且asnumber

这是我的网址

http://127.0.0.1:3232/listcdix/+custcode+/detail/+asnumber+

请检查我的照片 在此处输入图像描述

感谢您的关注

标签: javascriptphpjquerylaravel

解决方案


你可以使用类似的东西

 window.location = "{{route('remindHelper',['id'=>"custcode",'asnumber'=>"asnumber"])}}";

因为在 laravel 中使用花括号 {{}} 时。您不需要将其与 ++ 连接。这就是为什么您可以将其用作简单格式的原因。我也检查了这段代码,所以这对你来说是 100% 的。

谢谢你。


推荐阅读