我正在phonegap/cordova 1.7.0上工作。我正在向服务器发送ajax请求。 我需要设置一个超时以便模拟它我已经在服务器端包含一个睡眠(30),并且在客户端我的js的时间超出了30000.Phonegap 1.7.0 ajax超时不工作
经过测试,我断定Android完全忽略检查超时,iOS不能完成ajax调用,但不会给出任何错误。
有人可以帮助我吗?是否ajax超时在phonegap下不起作用,是否有另一种方法来检查phonegap超时? 这里是js代码:
$.ajax({
url: url,
data: data,
type: 'GET',
dataType: data_type,
timeout:3000,
error: function(xhr, status, error){
$('body').trigger('network-error') // triggers standard network error
console.log('network-error')
console.log('request came back with the error '+error)
CallbackFail()
},
success: function(data){
// is called from aSuccessCallback in the return
console.log('success')
console.log(data)
}
})
编辑
我忘了提一大点,我并没有直接使用jQuery而是仄。
好问题,我对这个问题也感兴趣。 – 2012-08-10 15:01:40