weixin_33737774 2011-07-02 01:33 采纳率: 0%
浏览 118

如何解决移动浏览器中的$ .ajax错误?

这太奇怪了!自昨晚以来该脚本就仅能在移动safari上使用:

 function login(login) 
{
        scrollTo(0,0);      
        var persistent = 'false'
            if ($('#persistent').is(':checked')){persistent = 'true';}
            if ($('#loginMsg').is(":visible")) {$('#loginMsg').hide();}
            var password = $('#password').val(); 
            var email = $('#email').val();
    $.ajax({
        type: "POST",
        url: "rpc.php",
        data: { id: email, value: password, persistent: persistent, method: "loginM"},      
        dataType: "json",
        timeout: 5000,
        success:    function(data){

        if (data.login=='true')
            {
            $('#pleaseWait').jqmShow(); 
            location.reload(true);
            }           
        else
            {   
            $("#loginMsg").show();
            $("#loginMsg").html(data.status);   
            }   
        },  
        /* error: function() {
        alert('This is taking too long. You could try again now, or wait and try again later.');*/ 

        error:function (xhr, ajaxOptions, thrownError){
                alert(xhr.status);
               alert(xhr.statusText);      
    }
});
}   
  1. alert(XMLHttpRequest.responseText); - 返回整个页面脚本
  2. alert(textStatus); - 返回 'ok'
  3. alert(errorThrown); - 返回 '200'

当我运行脚本时,它不出5秒钟就会出错,不需要等待。我已经隔离了脚本,因此其他脚本不会干扰它。我还试过清除ipod上的缓存、重启服务器,但都不可行。

这似乎是个普遍的问题,请帮帮我吧。
  • 写回答

1条回答 默认 最新

  • 狐狸.fox 2011-07-02 02:02
    关注

    The URL is relative. It should be absolute like : http://myserver.com/rpc.php

    评论

报告相同问题?

悬赏问题

  • ¥15 vhdl+MODELSIM
  • ¥20 simulink中怎么使用solve函数?
  • ¥30 dspbuilder中使用signalcompiler时报错Error during compilation: Fitter failed,求解决办法
  • ¥15 gwas 分析-数据质控之过滤稀有突变中出现的问题
  • ¥15 没有注册类 (异常来自 HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))
  • ¥15 知识蒸馏实战博客问题
  • ¥15 用PLC设计纸袋糊底机送料系统
  • ¥15 simulink仿真中dtc控制永磁同步电机如何控制开关频率
  • ¥15 用C语言输入方程怎么
  • ¥15 网站显示不安全连接问题