I use ajax with jquery and when I tried to display the result in popup.
Then alert always displays 0
success : function(results) {
alert(results); }
EDIT :
var dataToSend = { action:"ACTION_NAME", id : "12" }; url_action = 'http://www.______.com/wp-admin/admin-ajax.php'; $.ajax({ url: url_action, type:'POST', data: dataToSend, success:function(results) { alert(results); } });
You can check when exactly it returns "success" : // If successful, handle type chaining if ( status >= 200 && status < 300 || status === 304 ) { ... // If not modified if ( status === 304 ) { statusText = "notmodified"; ... // If we have data } else { try { ...
What is AJAX success? AJAX success is a global event. Global events are triggered on the document to call any handlers who may be listening. The ajaxSuccess event is only called if the request is successful. It is essentially a type function that's called when a request proceeds.
ajax method lets you set a timeout in milli seconds. When a timeout happens, The fail callback is called, with errorThrown set to "timeout". The request is aborted, meaning that even if the response arrives later on, your done callback is not called by jQuery.
The parameter is not being deprecated, the success method is. You can continue using success: function re-read it carefully.
Try to add die();
or exit();
at the very last line of the function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With