Advertisement
Guest User

Untitled

a guest
May 2nd, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. <?php
  2. add_action( 'wp_ajax_my_action', 'my_action_callback' );
  3.  
  4. function my_action_callback() {
  5. wp_die($_POST);
  6. }
  7.  
  8. ?>
  9. <script>
  10.  
  11.  
  12. function ajax_test(){
  13.  
  14. var str = $('#post').serialize() + '&action=my_action';
  15.  
  16. $.ajax({
  17. type: 'POST',
  18. url: ajaxurl,
  19. data: str,
  20. success: function(data){
  21. console.log(data);
  22. },
  23. error : function (jqXHR, textStatus, errorThrown) {
  24. $('body').html(jqXHR + ' :: ' + textStatus + ' :: ' + errorThrown);
  25. }
  26. });
  27. return false;
  28. }
  29.  
  30. setInterval(function(){ajax_test();}, 20000);
  31. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement