Laravel Classroom image

osdyui
 
To post your Question Join Classroom
 
Lesson Topics's No:-  First|1 | 2 | 3 | 4 | 5 | 6|Last
Lessons:-AJAX Content

22.3 Post Data
Sometimes you need to send extra along with your requests, let’s create a new POST HTTP request
with jQuery to demonstrate how this can be done. First we will need a route that will respond
to a POST request.
1 <?php
2
4 Route::post('content', function() {
5 // deal with the post data..
6 });
By using the Route::post() method instead of get() our content route will now respond to our
POST request, let’s get started on the Javascript.
1 // attempt a POST request with
2 // some additional data
3 $.post(BASE+'content', {
4 name: "Dayle",
5 age: 27
6 }, function(data) {
7 $('#content').html(data);
8 });
We are using the POST method to post some data to the content route, we can receive the data
with Laravel in a similar manner to form processing using the Input class.
1 <?php
2
3 // application/routes.php
4 Route::post('content', function() {
5 echo Input::get('name'); // Dayle
6 echo Input::get('age'); // 27
7 });
Simple as that!3 // application/routes.php

 

 
 
 

osdyui

Skills    Laravel

Qualifications :-
Location :-,,,
Description:-
Explore
 

  Students (0)