Vin*_*kar 2 javascript jquery jquery-mobile
我试图$.mobile.showPageLoadingMsg()在用户点击登录按钮后使用jquery mobile .在这个操作之后我正在对webservice进行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();
Run Code Online (Sandbox Code Playgroud)
我还发现,如果我给hidePageLoadingMsg提供超时,那么加载器会显示出来.
setTimeout(function(){$.mobile.hidePageLoadingMsg()},5000);
Run Code Online (Sandbox Code Playgroud)
加载器需要更多时间才能显示出来,即它在ajax调用后显示并显示5秒.由于给出超时不是一个修复.请帮忙.
首先,$.mobile.showPageLoadingMsg()和$.mobile.hidePageLoadingMsg()被弃用作为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);
});
Run Code Online (Sandbox Code Playgroud)
请参阅jsFiddle在这里模拟冗长的工作
| 归档时间: |
|
| 查看次数: |
9616 次 |
| 最近记录: |