I am using an Ajax post to submit form data to the server, be validated and then return a message based on whether or not the data was valid and could be stored. My success
The answer given above can't solve my problem.So I change async into false to get the alert message.
jQuery.ajax({ type:"post", dataType:"json", async: false, url: myAjax.ajaxurl, data: {action: 'submit_data', info: info}, success: function(data) { alert("Data was succesfully captured"); }, });