ajax代码在android上工作,在iOS上失败
我写了一个在安卓上完美运行的应用程序。我已经为 iOS 版本输入了相同的代码,并将其加载到我的 iPod touch 2nd gen 上。应用程序中的所有内容都显示正常,但似乎无法发送/接收 ajax 请求。在我的应用程序上有一个登录,我使用 ajax 调用来登录。ipod 可以正常连接到互联网,所以我不太确定为什么这段代码不起作用。
是因为手机旧了?我构建的应用程序支持 iOS 3.0。还有什么可能呢?
谢谢
编辑: 是的,这纯粹是一个网络应用程序,我正在处理 ajax 问题。这是特别的部分:
$.ajax({
type: "POST",
url: "https://website.com/a/login/",
data: data,
dataType: "json",
async: false
}).success(function (data) {
window.localStorage.setItem("token", data["token"]);
window.localStorage.setItem("oid", data["oid"]);
// alert(data["token"]);
}).error(function (a, b, c) {
$('#submit').button('enable');
alert("One of your credentials is incorrect, please try again");
});
I have written an app that works perfectly on the android. I have put in the same code for the iOS version and loaded it up on my ipod touch 2nd gen. Everything in the app shows up fine, but it seems unable to send/receive ajax request. On my app there is a login and I use an ajax call to log in. The ipod is connecting to the internet fine, so I'm not quite sure why this code isn't working.
Is it because its an old phone? I built the app to support as far as iOS 3.0. What else could be possible?
thanks
EDIT:
yes this is purely a webapp, and I'm dealing with ajax issues. This is the part in particular:
$.ajax({
type: "POST",
url: "https://website.com/a/login/",
data: data,
dataType: "json",
async: false
}).success(function (data) {
window.localStorage.setItem("token", data["token"]);
window.localStorage.setItem("oid", data["oid"]);
// alert(data["token"]);
}).error(function (a, b, c) {
$('#submit').button('enable');
alert("One of your credentials is incorrect, please try again");
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我要检查的两件事...
1 - 您是否在 PhoneGap.plist 中的“ExternalHosts”键下添加了主机?
2 - SSL 证书是自签名的吗? <- 如果没有 Objective-C 插件,这将无法工作
这两个项目都在这里讨论: http://wiki.phonegap.com/w/page/41631150/PhoneGap%20for%20iOS%20FAQ
2 things I would check...
1 - did you add the host in PhoneGap.plist under the "ExternalHosts" key?
2 - is the SSL cert self signed? <- this doesn't work without an Objective-C plugin
Both items are discussed here: http://wiki.phonegap.com/w/page/41631150/PhoneGap%20for%20iOS%20FAQ
如果 Deric 的第一个建议不起作用,您可以尝试将其添加到 AppDelegate.m 的末尾
If Deric's first suggestion didn't work you can try to add this at the end of you AppDelegate.m