0

Proceed to booking on clicking the button i call the ajax function code below

$("#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

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

Controller

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

       $input = $req->all();
       return view ('pages.roombooking')->with('id',$id);
    }
1
  • 1
    what is your question? You have an ajax GET but your route is POST Commented Jun 22, 2016 at 22:01

1 Answer 1

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

change to

Route::get('roombooking','pagescontroller@roombooking');
Sign up to request clarification or add additional context in comments.

4 Comments

i did it but still m not able to redirect to another view
What do you mean? You send request by ajax and need to redirect to another view? even though you can use location.href in javascript to redirect page, but why you need to do it?
I have a page that list data in bootstrap table with checkbox . So now when the user checks in multiple item from the table i want those item id to be send to the controller through ajax and in the controller i will check the id in the database and fetch my desired data and in another view want to list those data. please help... also if there is any alternative -
So please show the error you got. If you use form then submit, remember stop the default event (event.preventDefault()) before sending data by ajax

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.