javascript returns a error 'Method not allowed' when it calls to url has parameters.
HTML
1.- <a href="{{ URL::to('acceso', ['option'=>'1']) }}">Acceso</a>
2.- <a href="{{ URL('acceso') }}">Acceso 2</a>
First option return a error. Second option work well.
This is the Route:
Route::get('/acceso/{option?}', function ($option = '') {
return view('acceso_Usuario')->with('option', $option);
});
Route::post('call', 'example_Controller@function_example');
This is the Controller:
class example_Controller extends Controller
{
public function function_example(Request $request)
{
if ($request->ajax()) {
return response()->json([
]);
}
}
}
and this is the javascript
$(document).ready(function() {
var route = "call";
var token = $("#token").val();
var parameters=
{
};
$.ajax({
url: route,
headers: {'X-CSRF-TOKEN': token},
type: 'post',
dataType: 'json',
data: parameters,
contentType: 'application/x-www-form-urlencoded',
success: function (data) {
},
error: function (msj) {
alert("Error Ajax);
}
});
});
someone who can help me! :)