1)
<?php namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
class AjaxController extends Controller {
public function request(Request $request) {
if($request->ajax()){
$param = $request->input('param');
echo json_encode($param);
}
}
}
2)
Route::post('ajax/request', 'AjaxController@request');
3)
jQuery.ajax({
url: location.origin + '/ajax/request',
async: false,
type: 'POST',
data: {'param': '32'},
dataType: 'json',
success: function(data) {
alert(data);
},
error: function() {
alert('Ошибка');
}
});