移动 Safari 上的 $.ajax 错误

发布于 2024-11-18 07:03:36 字数 1521 浏览 2 评论 0原文

这很奇怪。

仅在移动 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 上的缓存。

这似乎是一个很常见的问题。一种解决方案似乎是重新启动服务器,但这不是一种选择。

This is weird.

Only on mobile safari, and since last night this script....

 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); - returns me the entire script for the page
  2. alert(textStatus); - returns 'ok'
  3. alert(errorThrown); - returns '200'

When I run the script it errors immediately, doesn't wait 5 seconds. I have quarantined the script so it is by itself so other scripts don't interfere with it. Cleared the cache on the ipod.

This seems quite a common problem. One solution seems to be rebooting the sever which isn't an option.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夏末 2024-11-25 07:03:36

URL 是相对的。它应该绝对像: http://myserver.com/rpc.php

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文