user2234992
user2234992

Reputation: 575

ajax call executes without ajax complete

I am calling a file with ajax. The ajax call works fine when I remove ajaxcomplete code line. But the data that prints is not satisfactory. How do I find what is making my ajaxcomplete, incomplete.. Help me figure out this.

Thank you.

What is that I need to do here? Thanks..

When I use the script below,I get the response in firebug, but it is not displaying.

ajax script

$("#form1").validate({
    debug: true,
    rules: {
        plid: "required",
    },
    messages: {
        plid: "Please select a pack name id..",
    },
    submitHandler: function (form) {
        loading_show();
        $.ajax({
            type: "POST",
            url: "load_data.php",
            data: $('#form1').serialize() + "&page=1",
            success: function (msg) {
                $("#container").ajaxComplete(function (event, request, settings) {
                    loading_hide();
                    $("#container").html(msg);
                });
            }
        });
    }
});

Upvotes: 0

Views: 173

Answers (3)

user428517
user428517

Reputation: 4193

If you're using success in your Ajax object, there's no need to use .ajaxComplete(). Just take it out:

$.ajax({
    type: "POST",
    url: "load_data.php",
    data: $('#form1').serialize() + "&page=1",
    success: function(msg) {
        loading_hide();
        $("#container").html(msg);
    }
});

Upvotes: 3

user1
user1

Reputation: 1065

You can use the code below for accomplishing the task.

$(document).ajaxComplete(function () { loading_hide(); });

or you can use ajax start and stop.

$(document).ajaxStart(function () { loading_show(); }); $(document).ajaxStop(function () { loading_hide(); });

Upvotes: 0

palaѕн
palaѕн

Reputation: 73946

As of jQuery 1.8, the .ajaxComplete() method should only be attached to document.

$(document).ajaxComplete(function (event, request, settings) {
    // Your code here
});

Upvotes: 1

Related Questions