Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/275.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将javascript变量传递到laravel路由?_Javascript_Php_Laravel - Fatal编程技术网

如何将javascript变量传递到laravel路由?

如何将javascript变量传递到laravel路由?,javascript,php,laravel,Javascript,Php,Laravel,脚本代码: <script type="text/javascript"> function getValue(){ var getvalue=document.getElementById('brand').value; window.location='products' +getvalue; } </script> Route::get('products/{getvalue}','categoryController@bValue');

脚本代码:

 <script type="text/javascript">
  function getValue(){
    var getvalue=document.getElementById('brand').value;
    window.location='products' +getvalue;
  }
</script>
Route::get('products/{getvalue}','categoryController@bValue');
  public function bValue(Request $getvalue)
{

    echo $getvalue;
}
这是我的路线。在这里,我试图将getvalue传递给控制器

控制器代码:

 <script type="text/javascript">
  function getValue(){
    var getvalue=document.getElementById('brand').value;
    window.location='products' +getvalue;
  }
</script>
Route::get('products/{getvalue}','categoryController@bValue');
  public function bValue(Request $getvalue)
{

    echo $getvalue;
}

试试这个,也许会管用的

 // Javascript
    <script type="text/javascript">
      function getValue(){
        var getvalue=document.getElementById('brand').value;
        window.location='products/' +getvalue;
      }
    </script>

// Php
    public function bValue($getvalue)
    {
        echo $getvalue;
    }
//Javascript
函数getValue(){
var getvalue=document.getElementById('brand').value;
window.location='products/'+getvalue;
}
//Php
公共函数bValue($getvalue)
{
echo$getvalue;
}

不是这样的,当路线被称为“产品/食品”时,食品将是你的getValue。如何给出你所提到的路线名称。您有任何错误吗?请参阅更新的答案…您可以参考此。你会有主意的。。