0

我正在用ajax调用一个文件。当我删除 ajaxcomplete 代码行时,ajax 调用工作正常。但打印出来的数据却不尽如人意。我如何找到使我的 ajax 完整、不完整的原因。帮助我弄清楚这一点。

谢谢你。

我需要在这里做什么?谢谢..

当我使用下面的脚本时,我在 firebug 中得到响应,但它没有显示。

ajax 脚本

$("#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);
                });
            }
        });
    }
});
4

3 回答 3

3

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);
    }
});
于 2013-05-15T18:25:27.853 回答
1

从 jQuery 1.8 开始,该.ajaxComplete()方法只能附加到document.

$(document).ajaxComplete(function (event, request, settings) {
    // Your code here
});
于 2013-05-15T18:22:16.643 回答
0

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(); });

于 2013-05-15T18:25:13.983 回答