SHARE
TWEET

Untitled

a guest Sep 16th, 2019 94 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function test(){
  2.     echo '123';
  3.    die();
  4. }
  5. add_action('wp_ajax_test', 'test');
  6. add_action('wp_ajax_nopriv_test', 'test');
  7.  
  8. ====== AJAX
  9. $('#gift_pillow').on('click',function(e) {
  10.                 e.preventDefault();
  11.                 console.log(ajaxurl);
  12.                 $.ajax({
  13.                     url: ajaxurl,
  14.                     type: 'POST',
  15.                     data: {
  16.                         action:'test'
  17.                     }
  18.                 }).done( function (response) {
  19.                     console.log(response);
  20.                     if( response.error != 'undefined' && response.error ){
  21.                         return true;
  22.                     } else {
  23.                         window.location.href = '/cart/';
  24.                     }
  25.                 });
  26.             });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top