显示加载GIF图像,同时加载与AJAX加载、图像、GIF、AJAX

2023-09-10 21:08:07 作者:长遥海

   $.ajax({
        url: "/image/productImages.jpg",
        timeout:5000,

        beforeSend: function(){
    // Handle the beforeSend event
        $('##loading').show();
        },

        complete: function(){
        // Handle the complete event
        $('##loading').hide();
        },

        success: function (data) {
            alert("image was added successfully");
        },

        error: function () {
            alert("There was an error. Image could not be added, please try again");
        }
    });

我想显示显示加载GIF图像时加载,然后一旦图像加载将其删除。在这里,我有这个code要做到这一点,但是,这是直行错误。没有任何人有任何想法,为什么或如何解决这一问题。在此先感谢!

I'm want to show display loading gif while image is loading and then remove it once image is loaded. Here I have this code to do that but, this is going straight to error. does anyone have any idea why or how to fix this. Thanks in advance!

推荐答案

您的ID选择有两个哈希值,

Your id selector has two hashes,

试试这个来代替:

 $('#loading').show();