gpt4 book ai didi

javascript - jQuery Mobile showPageLoadingMsg()/hidePageLoadingMsg() 方法仅适用于 Firefox 浏览器

转载 作者:行者123 更新时间:2023-12-01 02:12:23 24 4
gpt4 key购买 nike

我尝试在用户点击后使用 jquery mobile $.mobile.showPageLoadingMsg()登录按钮。执行此操作后,我将对 Web 服务进行 ajax 调用得到回复后我隐藏了加载消息。问题问题是加载程序仅在 Firefox 浏览器中显示,而在其他浏览器(chrome、safari、android)中不显示。

示例:

$.mobile.showPageLoadingMsg();
var response = $.ajax(
{
type: "POST",
url: "service.php",
data: "...",
async: false,
dataType: "json",
cache: false
});
response.success(function (data)
{
res_content = data;
});
response.error(function (jqXHR, textStatus, errorThrown)
{
}
$.mobile.hidePageLoadingMsg();

我还发现,如果我给隐藏PageLoadingMsg。

setTimeout(function(){$.mobile.hidePageLoadingMsg()},5000);

加载程序需要更多时间才能显示,即它在 ajax 调用后显示并显示 5 秒。因为给出超时并不是解决办法。请帮忙。

最佳答案

首先,$.mobile.showPageLoadingMsg()$.mobile.hidePageLoadingMsg()deprecated从 jQM 版本 1.2 开始。请改用 $.mobile.loading('show')$.mobile.loading('hide')

话虽这么说,你可以尝试类似的事情

$("#btn1").click(function(){
$.mobile.loading('show', {theme:"e", text:"Please wait...", textonly:true, textVisible: true});

//Do your ajax call and processing here
setTimeout(function(){
$.ajax({
...
success: function (data){
...
$.mobile.loading('hide');
}
});
}, 50);
});

参见jsFiddle在这里模拟漫长的工作

关于javascript - jQuery Mobile showPageLoadingMsg()/hidePageLoadingMsg() 方法仅适用于 Firefox 浏览器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14556289/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com