Welcome Guest, Not a member yet? Register   Sign In
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



Theme © iAndrew 2016 - Forum software by © MyBB