I have a prescription form and submitted the form using AJAX.
Now I want to automatically redirect to another route from AJAX after the form successfully submitted.
I have tried with several options like
window.location.href = "{ url('/show-all-prescription') }"
and
{{ route('/show-all-prescription')}}
AJAX CODE
jQuery.ajax({
url:"{{ url('/submit_prescription') }}",
type: 'GET',
data: {name: name, age: age, mobile_no: mobile_no},
success:function(msg){
if(msg>0)
{
// window.location.href = "{ url('/show-all-prescription') }";
{{ route('/show-all-prescription')}}
}
}
});
And got the error
Route [/show-all-prescription] not defined
route.php
Route::get('/show-all-prescription', 'prescriptionController@show_all_prescription');
But not getting the result. Someone Help Please?
In route file
Route::get('/show-all-prescription', 'prescriptionController@show_all_prescription')->name('show-all-prescription');
Then in blade file ajax request,
window.location.href = "{{ route('show-all-prescription')}}";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With