I have a blade view name: create.blade.php
. From here I want to call an ajax request to show a data in this blade.
{!! Form::open() !!}
<p data-toggle="modal" data-id="" data-target="#subcategory_Modal" class="CategoryIDForModal">
</p>
{!! Form::close() !!}
From here I will collect id
.
Let's see the ajax request:
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('[name="_token"]').val()
}
});
$(".CategoryIDForModal").click(function (e) {
//console.log("I am inside Call");
var id = $(this).data(id);
e.preventDefault();
$.ajax({
type: 'POST',
url: '/pos/create',
data: {id: id},
success: function (data) {
console.log("YES");
}
})
})
Now see the Route:
Route::post('/pos/create', 'SellPosController@ajaxRequestForSubCategoryPost');
With my controller I just want to pass a variable in my create.blade.php
file.
public function ajaxRequestForSubCategoryPost(Request $request)
{
$input = $request->all();
return view('sale_post.create', ['inputD' => $input]);
}
But getting error:
POST http://localhost:8000/pos/create 500 (Internal Server Error)
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire