Your article very good
I always code like you :)
But i think bester on success
success: function(response) {
console.log(response);
if(response.status == 'success'){
// Action for success submit (update,post)
}
else{
// Action for error
}
}
Thanks, you are right I should have planned for a possible error. Maybe between my code and your added code, it will help someone. I admit my first post a couple weeks ago on this was hard to read the code.
I've extended the jquery ajax writing my own exception handler to show the user a js msg box.
When an error occurs in the laravel controller it throws an exception which will output a json string with the exception message as a response to the user. The ajax transport listener will show appropriate msg with the response.
I hate to spoil the party but do we really want this code on the forum as a Laravel example?
Well this is the way to post using jquery, and newbees ask this question over and over. Funny you didn't offer your solution with an example. No offence, but put up code or shut up should be the way it works.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community