如何使用jQuery显示隐藏元素
我的页面上有一个忙碌的图标,其类别为隐藏".当用户单击按钮开始处理输入数据时,我要显示忙碌图标.我正在用
I have a busy icon on my page which has a class of "hidden". When the user clicks a button to start processing input data, I want to show the busy icon. I am doing this with
$("#busy").removeClass("hidden");
在删除隐藏类之后,我立即使用AJAX从服务器获取一些数据,将其显示在页面上,然后将隐藏类添加回繁忙的图像中.
Immediately after removing the hidden class, I use AJAX to get some data from the server, display it on the page and add the hidden class back to the busy image.
我的问题是,忙碌的图标永远不会显示.我不是javascript/jQuery专家,但我认为这是因为直到脚本执行完毕后页面才会重绘?
My problem is that the busy icon is never displayed. I'm not a javascript/jQuery expert but I think this is because the page isn't redrawn until after the script has finished executing?
在进行AJAX处理时如何显示忙碌图标?
How can I get the busy icon to display while the AJAX processing is in progress?
尝试一下
首先在div上链接您的图片
First u link ur image on a div
然后
尝试一下,它将正常工作
Try this, it will work fine
$.ajax({
url : "URL",
data: { data },
beforeSend: function(){
$("#loading").show();
},
complete: function(){
$("#loading").hide();
},
success: function (response) {
});
});