I have this script:
$(window).keydown(function(e){
if(e.keyCode == 30){
coolStuff();
}
});
I would like to use Laravel/PHP functions inside javascript like User::all()->something to change data in db. But as you know if i just write it like that it will run when the page renders, without waiting for "if" condition.
Did a little search and seems like AJAX is the only way out. But what if the user is a developer and changes ajax codes (also the sent data) ? It will execute important actions like banning user so it's quite important to protect the sent data (user id).
What is the best way to handle this situation ? My bet is putting crucial data in session flash and then posting to some Route.
Any idea is appreciated. Thanks in advance
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire