我正在开发一个cordova混合应用程序(目前用于Android)并使用InAppBrowswer-Plugin。
我想打开一个网页并使用发布请求登录(因为它目前通过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中
答案 0 :(得分:2)
只是为了帮助通过Google找到此问题的任何人,解决方案是described at that answer,如问题评论中所述。
代码,更改特定上下文的值如下:
AVVideoCompositionCoreAnimationTool