I use $("form").serialize() to submit form data. while I return value from a method it works fine. My method code is as below.
public function store(Request $request)
{
$list = @$request['lists'];
$total_amount = @$request->total_amount;
$r_g_amount = @$request->r_g_amount;
$type = @$request->type;
$cash = @$request->cash;
$credit = @$request->credit;
$bank = @$request->bank;
$from = @$request->from;
$to = @$request->to;
return $cash;
}
it sends me null value, if I return $request->formdata then it sends me all details of form. formdata is variable which I pass from ajax as formdata:$("form").serialize().
so how can I get values of form data into variable.
ajax request
$.ajax({
url: "{{ route('HK.store') }}",
data: {
lists: list, total_amount: total_amount, formdata : $("form").serialize(), "_token": "{{ csrf_token() }}"
},
type: "POST",
success: function (data) {
console.log(data);
}
});
enter code here