最简单的显示方式"装载"使用jquery Ajax时? [英] easiest way to show "loading" when using jquery ajax?

查看:92
本文介绍了最简单的显示方式"装载"使用jquery Ajax时?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道,呈现出​​装载GIF到一个特定的jQuery Ajax请求的最简单的方法。

I want to know the easiest way of showing a 'loading' gif to a specific jquery ajax request.

我已经尝试过:

$(document).ajaxStart(function() {
    $('.hideOnLoad').hide();
});
$(document).ajaxStop(function() {
    $('.hideOnLoad').show();
});

但后来所有的Ajax请求将触发它。我只想要一个特定的jQuery Ajax请求触发装载过程(也许GIF将显示)。

but then ALL ajax requests will trigger it. i just want a specific jquery ajax request to trigger the loading process (maybe a gif will be shown).

我该怎么办呢?

推荐答案

beforeSend 回调,你必须表现出微调和完整你必须把它藏起来。仅供参考: ajaxStart ajaxStop 是全球性的AJAX事件,而 beforeSend 完整是本地的。

In beforeSend callback you have to show the spinner and in complete you have to hide it. Just FYI: ajaxStart and ajaxStop are global ajax events while beforeSend and complete are local.

这篇关于最简单的显示方式"装载"使用jquery Ajax时?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆