Sunday, June 2, 2024
 Popular · Latest · Hot · Upcoming
69
rated 0 times [  71] [ 2]  / answers: 1 / hits: 36052  / 5 Years ago, sat, april 6, 2019, 12:00:00

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?


More From » php

 Answers
6

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')}};

[#52297] Saturday, March 30, 2019, 5 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dorothylorrainef

Total Points: 456
Total Questions: 102
Total Answers: 115

Location: El Salvador
Member since Sun, Sep 12, 2021
3 Years ago
;