【问题标题】:I want to add ajax loading gif to my website but my code is not working我想将 ajax 加载 gif 添加到我的网站,但我的代码不起作用
【发布时间】:2012-09-08 19:37:16
【问题描述】:

我正在为我的网站 http://notes-store.com/ 开发一个上传器

我想在使用 AJAX 加载带有我的子类别选项的选择框时显示正在加载的 .gif 图像。

我当前的代码:

function category_change(kuchbhi) {
    var catID = $(kuchbhi).val();   
    $.ajax({
        type: "GET",
        url: "subCategory.php?category="+catID,
        beforeSend: function () {
             $("#loder").html('<img src="images/loader.gif" /> Now loding...');
        },
        success: function(data){
            $('#select3').html(data);
        }
     });
}

【问题讨论】:

    标签: php html ajax gif loader


    【解决方案1】:

    为什么不在函数启动时添加,调用成功时移除:

    function category_change(kuchbhi) {
        $("#loder").html('<img src="images/loader.gif" /> Now loding...');
        var catID = $(kuchbhi).val();   
        $.ajax({
            type: "GET",
            url: "subCategory.php?category="+catID,
            success: function(data){
                $('#select3').html(data);
                $("#loder").html('');
            }
        });
    }
    

    注意:您的选择器是 #loder 而不是 #loader

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-02-18
      • 2022-01-23
      • 1970-01-01
      • 2021-10-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多