2
我正在开发一个科尔多瓦混合应用程序(目前为Android)和使用InAppBrowswer插件。发送请求在科尔多瓦InAppBrowser
我想打开一个网页,并使用发布请求在那里登录(因为它目前通过Java在实际的Android应用程序中完成)。
不知何故,这不工作,但我不明白为什么。这是我正在使用的代码:
var ref = cordova.InAppBrowser.open("www.thesite.dummy", "_blank", "location=yes");
var postAsString = 'var xhttp = new XMLHttpRequest();'+
'xhttp.open("POST", "'+url+'", true);'+
'xhttp.onreadystatechange = function() {if (xhttp.readyState == 4 && xhttp.status == 200) {alert("it worked")}};'+
'xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");'+
'xhttp.send("username=dummyUser&password=dummyPW")'
console.log(postAsString);
ref.executeScript({"code":postAsString});
正如你所见,我也console.log我的“postAsString”。如果我复制这个字符串并在www.thesite.dummy的控制台中执行它,它实际上可行,但不适用于InAppBrwoser
貌似https://stackoverflow.com/questions/37526321/cordova-inappbrowser-post-form-to-url的副本对我来说 – Jannis
将更有意义的称为新的重复,但我同意。问题是相同的 – Sergej