massum
177
23
Laravel

pass data from ajax to controller in laravel

Posted 2 years ago by massum

i am having a problem in sending ajax get request to fetch the data in to the controller. what i am trying to achieve is the data i am sending through ajax i should be able to access those data and send it to another view. i am sharing my code below plz help javascript

$.ajax({
              url: 'roombooking',
              type: "get",
              data: {id:data},
               success: function(response){ // What to do if we succeed
              if(data == "success")
            alert(response); 
        }
            });
route file
Route::post('roombooking','[email protected]');
controller file
public function roombooking(request $request)
    {
     //redirect('pages.roombooking');
     //return 'success';
      $data= $request->dataval;
      return $data;
     // return view ('pages.roombooking') ;
      //return View::make('pages.roombooking')-with(compact('success'));
      //return view('pages.roombooking');

    }

Please sign in or create an account to participate in this conversation.

Laracasts Mascot

Hi, Have We Met Yet?

Did you know that, in addition to the forum, Laracasts includes well over 1000 lessons on modern web development? All for the price of one lunch out per month.

Sign Me Up

Channels

Reply to

Use Markdown with GitHub-flavored code blocks.