Reputation:
I have created a bootstrap modal with some input fields and I am trying to pass those input values to controller and need to insert into db.But it displays null.
It will be helpful if anyone solves my issue.
Upvotes: 0
Views: 496
Reputation: 21691
You just need to change the JS code and laravel redirection with JSON format data like answered by Don't Panic. Added here for other people help so credit goes to him.
JS code:
$("#priceSave").click(function(e){
e.preventDefault();
var data = $('form').serialize();
$.ajax({
url: 'addPriceDetails/{{$dataId}}',
type: "post",
data: data,
dataType: 'json',
success: function(response) {
alert(response.SKUID);
}
});
});
Controller code:
public function addPriceDetails(Request $priceform,$dataId) {
// ... all your code
return response()->json([
'SKUID' => $priceInfo->SKUID,
'listingStatus' => $priceInfo->listingStatus
// ... any other fields you want to return
]);
Upvotes: 1