由于某种原因,回调无法启动。我去掉了所有多余的代码,这就是结构。也许我看不出这里有什么不对劲?
(function() {
  registerSecendStep = new Page('registerSecendStep', function(name) { //CLIKED THE BUTTON
    $('.register-second-step-button').click(function() {
      function doAjax(testReferral) {
        alert(testReferral); //THIS NEVER GETS PRINTED
      }
      showHint(function() { doAjax(testReferral); }); //START THE CALL
    });
  });
  function showHint(callback) { //CALLBACK
    xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function() {
      if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
        alert('called'); //THIS GETS ALERTED
        callback(true);
      }
    }
    xmlhttp.open("GET", helper.app.HomeSite + "/ajaxresponder?w=" + str, true);
    xmlhttp.send();
  }
})();感谢您的任何帮助
https://stackoverflow.com/questions/51200717
复制相似问题