• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Ajax with CSRF causing a Double Post to controller

#6
HI,
I've run into similar issues myself in the past and the solution for me was to use  event.stopImmediatePropagation() function
Here is the link to this function: https://developer.mozilla.org/en-US/docs...ropagation

And here is an example implementation from one of my projects
PHP Code:
 $('#submitbtn').on('click', function (el) {
 
       var formDAta = $('#tagform').serialize();
 
       $.ajax({
 
           url'<?= site_url('tags/saveTags/entities/' . $id) ?>',
 
           method'POST',
 
           dataformDAta,
 
           success: function (data) {
 
               $('.collapse').toggle('toggle');
 
           }
 
       });

 
       // stop from calling this multiple times
 
       el.stopImmediatePropagation();
 
       return false;
 
   }); 
Reply


Messages In This Thread
RE: Ajax with CSRF causing a Double Post to controller - by qury - 10-03-2018, 02:37 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.