Advertisement
Guest User

Untitled

a guest
Oct 6th, 2015
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. (function($) {
  2.  
  3. $.ajax({
  4. url: ajaxurl,
  5. action: 'my_wp_ajax_action'
  6. })
  7. .success(function(response) {
  8. if (typeof response.success === 'undefined') {
  9. // undefined error
  10. } else if (response.success === false) {
  11. // error (sent with wp_send_json_error)
  12. } else if (response.success === true ) {
  13. // success (sent with wp_send_json_success)
  14. } else {
  15. // something weird has happened
  16. }
  17. })
  18. .fail(function() {
  19. // network issues / no response etc.
  20. })
  21. .always(function() {
  22. // always do this, whether the request was successful or not
  23. });
  24.  
  25. })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement