这段代码工作正常:
function callFromFlex(url, method, payload) {
console.log("call from Flex: " + method + " " + url + " " + payload);
var xhttp = new XMLHttpRequest();
xhttp.open(method, url, true);
xhttp.setRequestHeader("Content-Type", "application/json");
xhttp.onreadystatechange = function() {
console.log(xhttp.readyState);
if (xhttp.readyState == 4) {
console.log("trying to call flash...");
// Callback to Flash here
...
}
};
xhttp.send(payload);
}
Run Code Online (Sandbox Code Playgroud)
但这不会 - onreadystatechange 永远不会被调用:
function callFromFlex(url, method, payload) {
console.log("call from Flex: " + method + " " + url + " " + …Run Code Online (Sandbox Code Playgroud)