如何从ajax get方法向laravel中的控制器发送数据?

时间:2016-06-22 19:19:16

标签: ajax laravel-5

继续预订 单击按钮我调用下面的ajax功能代码

$("#add_cart").click(function() 
    {$.ajax({
              url: 'roombooking',
              type: "get",
              data: {id:data},
               success: function(response){ // What to do if we succeed
              if(data == "success")
               alert(response); 
               }
               });
              });

路线

Route::post('roombooking','pagescontroller@roombooking');

控制器

public function roombooking($id,request $req)
    {

       $input = $req->all();
       return view ('pages.roombooking')->with('id',$id);
    }

1 个答案:

答案 0 :(得分:0)

Route::post('roombooking','pagescontroller@roombooking');

更改为

Route::get('roombooking','pagescontroller@roombooking');