好的,所以我的任务是更新旧的Phonegap / jQuery应用程序。它已经过时了几年,但已经存在了一段时间并且工作正常。
我需要添加一些新功能,但大部分代码都不受影响。
所以我的问题是,我无法在 iOS 上获得我的$ .ajax调用,以便在我的生活中工作。我一直在阅读十亿个帖子并且没有运气就完成了以下所有操作:
访问来源
<access origin='*' />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
平台内容
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
添加了此插件
<gap:plugin name="cordova-plugin-transport-security" source="npm" spec="0.1.2" />
我也有这个插件,但根据我的理解,iOS不再需要它
<gap:plugin name="cordova-plugin-whitelist" source="npm" spec="1.3.1" />
继续......
关闭Ajax缓存
jQuery.ajaxSetup({cache: false});
不确定为什么我认为这会起作用......
在我的索引html中添加Content-Security-Policy元标记
<meta http-equiv="Content-Security-Policy" content="default-src * 'self' 'unsafe-inline' 'unsafe-eval' http://* https://* data: cdvfile://* content://* gap://ready file:;">
所以......现在我被卡住了。我正在测试我的新iOS 12测试版手机,但我不认为这是问题(可能是?怀疑它),但我的ajax调用永远不会发生。没有错误(我可以看到)或其他任何错误。
为了彻底,这是我的ajax电话。我没有改变这个,因为它在以前的版本中工作。
$.ajax({
type: "POST",
url: config.Path + '/account/login',
data: { email: email, password: password }
}).done(function (data) {
// It never gets here... ever.
});