我已经使用 Phonegap 在 Android 上开发了一个示例应用程序。
单击按钮时,会向服务器发出 Ajax 请求 (http://192.168.0.199:8080/test.php)。
test.php 只是回应 hello world。
我正在使用 Jquery 1.5 进行 Ajax 调用。
这是 Ajax 调用的代码:
$.ajax({
url:"http://192.168.0.199:8080/test.php",
beforeSend: function(x) {
alert("The URL "+url);
},
type:'POST',
crossDomain: true,
success:function(data) {
alert(data);
},
error:function(XMLHttpRequest,textStatus, errorThrown) {
alert("Error status :"+textStatus);
alert("Error type :"+errorThrown);
alert("Error message :"+XMLHttpRequest.responseXML);
}
});
但是,每次调用这个函数时,它都会抛出一个错误:
错误类型:无传输
错误信息:未定义
错误状态:错误
注意:我在 list 文件中添加了 INTERNET 权限。我使用的是运行 Android 1.6 的 G1 设备
提前致谢
最佳答案
看起来您正在尝试调用本地网络中的客户端。
尝试验证您有权访问该本地网络。
关于android - 在 Android 上发出 Ajax 请求返回 No Transport 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5104539/