移动 Safari 上的 $.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);
}
});
}
alert(XMLHttpRequest.responseText);
- 返回页面alert(textStatus);
的整个脚本- 返回 'ok'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);
}
});
}
alert(XMLHttpRequest.responseText);
- returns me the entire script for the pagealert(textStatus);
- returns 'ok'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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
URL 是相对的。它应该绝对像: http://myserver.com/rpc.php
The URL is relative. It should be absolute like : http://myserver.com/rpc.php