Advertisement
Guest User

Untitled

a guest
Aug 25th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. jQuery(document).ready(function($) {
  2.  
  3. var AjaxRunning = 0;
  4.  
  5. $('form').submit(function(event){
  6.  
  7. event.preventDefault();
  8.  
  9. if( !AjaxRunning ){
  10.  
  11. $.ajax({
  12. type: 'POST',
  13. url: AJAX.url,
  14. data: {
  15. action: 'my_ajax_function',
  16. nonce: AJAX.nonce,
  17. },
  18. dataType: 'json',
  19. beforeSend: function(){
  20. AjaxRunning++;
  21. },
  22. success: function( result ) {
  23. if (result.success) {
  24. console.log( 'success' + AjaxRunning );
  25. }
  26. },
  27. complete: function(){
  28. AjaxRunning--;
  29. }
  30. });
  31.  
  32. }
  33.  
  34. });
  35.  
  36. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement