user3818576 user3818576 - 1 month ago 5x
Ajax Question

how to know if ajax is complete in jquery?

There is a generated form from contact form 7 in wordpress.
I would like to know if this is the right way of coding in getting the output messages from contact form after it submit and return the messages (either success or not). This code work but it double send the ajax form.

ajaxArgs = {
url: '',
success: function () {
var a= $(".wpcf7-response-output").html();
$(".wpcf7-form").bind('submit', function() {

if you submit the form from contact form 7. it works in ajax way and I want to get the error or success message after it complete the ajax. I need your advice guys if this is good enough or please if you have a code that makes it better to use.

bot bot
    type : "POST",
    url : "${pageContext.request.contextPath}/yourUrl",
    data : {
        key1 : "value1" ,
        key2 : "value2"
    async : true, // if you want wait until ajax done, you should set "async" false
    complete : function(){
        console.log("[JQUERY AJAX COMPLETE]");
    success : function(){
    error : function () {

You can know ajax complete at "complete"