Laravel - JQuery preventDefault event not allowed to insert the records in the database?

-1

I used the following code JQuery to avoid reloading the page when inserting a record in the database. actually stopped reloading, but it is not allowing you to save the records to the bank.

$( "#btnAtividades" ).click(function( event ) {
      event.preventDefault();
});

I have been told that I have to do something else after the event, but nobody explains exactly what I found some examples, but it was pure PHP and I'm using Laravel.

    
asked by anonymous 02.01.2019 / 21:29

1 answer

0

The preventDefault causes the default behavior of the current event to be locked, in its case the click event, ie if you block the click event of the button that makes the submit of your form for Laravel, this form is never sent.

According to MDN, Event.preventDefault() :

  

Cancel the event if it is cancelable, without stopping the propagation of the event.

link

If you want to enter this data into Laravel without the page being reloaded, you can send via ajax with a POST method and have your controller return a successful http response (200) or some error if it occurs .

link

    
07.01.2019 / 03:37