mardi 9 mai 2017

Laravel: Ajax call using jquery

I am using Laravel 5.3 for my application. On a form, I am trying to make ajax call from javascript.

The jquery docs show how to give a static url for the ajax call.

$.ajax({
  url: "test.html",
  context: document.body
}).done(function() {
  $( this ).addClass( "done" );
});

I know I can substitute the test.html with any URI from my routes.php file. But I don't want it to be static. It would be better if I can call a Controller function. This will allow me to change the URI in future without changing the code.

In short, I need a way to call the action() function of Laravel in the javascript. How can I achieve this?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire