0
我正在构建Phonegap应用程序,并且我为iOS平台安装了插件WKWebView
。WKWebView xhr在phonegap项目中返回状态0并且readyState = 4
,我现在面临的问题是,当我使用xhr
谷歌从代码获得访问令牌做出post
我得到xhr
回报readyState = 4
和status = 0
如果我测试使用UIWebView
使用相同的代码一切工作正常。 Android
(没有WKWebView
)也是相同的代码工作正常。所以,这个问题仅是使用WKWebView
这里iOS
是后:
var xhr = new XMLHttpRequest();
var url = "https://accounts.google.com/o/oauth2/token";
var data = 'code=' + encodeURIComponent(code[1]) +
'&client_id=' + encodeURIComponent(this.gdrive_client_id) +
'&client_secret=' + encodeURIComponent(this.gdrive_client_secret) +
'&redirect_uri=http%3A%2F%2Flocalhost' +
'&grant_type=authorization_code'
xhr.open("POST", url, true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(data);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
console.log(xhr.status); //Here I get status 0
}
};
我使用WKWebView
verison 0.6.4
Phonegap
CLI版本5.5.2
平台:IOS 3.9.2