首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Javascript回调函数未启动

Javascript回调函数未启动
EN

Stack Overflow用户
提问于 2018-07-06 06:31:15
回答 1查看 46关注 0票数 0

由于某种原因,回调无法启动。我去掉了所有多余的代码,这就是结构。也许我看不出这里有什么不对劲?

代码语言:javascript
运行
复制
(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();
  }
})();

感谢您的任何帮助

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51200717

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档