相关疑难解决方法(0)

Jquery ajaxStart没有被触发

这段代码

$("#loading").ajaxStart(function() {
        alert("start");
        $(this).show();
    });
Run Code Online (Sandbox Code Playgroud)

在我的加价

<div style="text-align:center;"><img id="loading" src="../images/common/loading.gif" alt="" /></div>
Run Code Online (Sandbox Code Playgroud)

这是完整的ajax请求:

$.ajax({
        type: "POST",       

        url: "http://localhost/WebServices/Service.asmx/GetResults",

        data: jsonText,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function(response) {

            var results = (typeof response.d) == 'string' ? eval('(' + response.d + ')') : response.d;
            PopulateTree(results);
        },

        error: function(xhr, status, error) {
            var msg = JSON.parse(xhr.responseText);
            alert(msg.Message);


        }
    });

$("#loading").ajaxStart(function() {
        alert("start");
        $(this).show();
    });

    $("#loading").ajaxStop(function() {
        alert("stop");
        $(this).hide();
        $("#st-tree-container").show();

    });
Run Code Online (Sandbox Code Playgroud)

即使gif显示为旋转,也不会触发警报"开始".AjaxStop按预期触发.有什么想法吗?

ajax jquery

14
推荐指数
1
解决办法
2万
查看次数

当AJAX调用正在进行时显示"加载"图像

我有以下jQuery Ajax调用:

$.ajax({
                   type: "POST",
                   url: "addtobasket.php",
                   data: "sid=<?= $sid ?>&itemid=" + itemid + "&boxsize=" + boxsize + "&ext=" + extraval,
                   success: function(msg){
                     $.post("preorderbasket.php", { sid: "<?= $sid ?>", type: "pre" },
                     function(data){
                        $('.preorder').empty();
                         $('.preorder').append(data); 
                     }); 
                   }
                 });
Run Code Online (Sandbox Code Playgroud)

我想在ajax调用进行时显示图像.我怎样才能做到这一点?

谢谢,

javascript ajax jquery

9
推荐指数
2
解决办法
3万
查看次数

标签 统计

ajax ×2

jquery ×2

javascript ×1