小编dar*_*job的帖子

XMLHttpRequest 方法的顺序很重要吗?

这段代码工作正常:

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)

javascript flash xmlhttprequest call onreadystatechange

4
推荐指数
1
解决办法
763
查看次数