Created
October 6, 2015 14:45
-
-
Save danielhomer/9a3c82ff1f4fdc18a209 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
$.ajax({ | |
url: ajaxurl, | |
action: 'my_wp_ajax_action' | |
}) | |
.success(function(response) { | |
if (typeof response.success === 'undefined') { | |
// undefined error | |
} else if (response.success === false) { | |
// error (sent with wp_send_json_error) | |
} else if (response.success === true ) { | |
// success (sent with wp_send_json_success) | |
} else { | |
// something weird has happened | |
} | |
}) | |
.fail(function() { | |
// network issues / no response etc. | |
}) | |
.always(function() { | |
// always do this, whether the request was successful or not | |
}); | |
})(jQuery); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment