<bdo id='wgBv4'></bdo><ul id='wgBv4'></ul>

<small id='wgBv4'></small><noframes id='wgBv4'>

  • <tfoot id='wgBv4'></tfoot>
    <i id='wgBv4'><tr id='wgBv4'><dt id='wgBv4'><q id='wgBv4'><span id='wgBv4'><b id='wgBv4'><form id='wgBv4'><ins id='wgBv4'></ins><ul id='wgBv4'></ul><sub id='wgBv4'></sub></form><legend id='wgBv4'></legend><bdo id='wgBv4'><pre id='wgBv4'><center id='wgBv4'></center></pre></bdo></b><th id='wgBv4'></th></span></q></dt></tr></i><div id='wgBv4'><tfoot id='wgBv4'></tfoot><dl id='wgBv4'><fieldset id='wgBv4'></fieldset></dl></div>

        <legend id='wgBv4'><style id='wgBv4'><dir id='wgBv4'><q id='wgBv4'></q></dir></style></legend>

        如何将回调函数中的值返回给调用者?

        How can i return a value from a callback function to the caller?(如何将回调函数中的值返回给调用者?)
      1. <i id='gkZZV'><tr id='gkZZV'><dt id='gkZZV'><q id='gkZZV'><span id='gkZZV'><b id='gkZZV'><form id='gkZZV'><ins id='gkZZV'></ins><ul id='gkZZV'></ul><sub id='gkZZV'></sub></form><legend id='gkZZV'></legend><bdo id='gkZZV'><pre id='gkZZV'><center id='gkZZV'></center></pre></bdo></b><th id='gkZZV'></th></span></q></dt></tr></i><div id='gkZZV'><tfoot id='gkZZV'></tfoot><dl id='gkZZV'><fieldset id='gkZZV'></fieldset></dl></div>
        • <bdo id='gkZZV'></bdo><ul id='gkZZV'></ul>

              <tfoot id='gkZZV'></tfoot>
                  <tbody id='gkZZV'></tbody>
                <legend id='gkZZV'><style id='gkZZV'><dir id='gkZZV'><q id='gkZZV'></q></dir></style></legend>

                <small id='gkZZV'></small><noframes id='gkZZV'>

                  本文介绍了如何将回调函数中的值返回给调用者?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  如何让这个小函数imageExists"返回 ajax 请求是否成功?

                  How can i make this little function "imageExists" return wether the ajax request was successful or not?

                  function imageExists(path){
                      $.ajax({
                          url: path,
                          type: 'HEAD',
                          error:
                              function(){
                                  return false;
                              },
                          success:
                              function(){
                                  return true;
                              }
                      }); 
                  }
                  

                  推荐答案

                  我相信你必须使用同步模式并使用单独的a变量来存储返回值.

                  I believe you'll have to use synchronous mode and use a separate a variable for storing the return value.

                  function imageExists(path){
                      var isSuccess;
                      $.ajax({
                          url: path,
                          type: 'HEAD',
                          async: false,
                          error:
                              function(){
                                  isSuccess = false;
                                  return false;
                              },
                          success:
                              function(){
                                  isSuccess = true;
                                  return true;
                              }
                      });
                      return isSuccess;
                  }

                  这篇关于如何将回调函数中的值返回给调用者?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Pause youtube video, youtube api(暂停 youtube 视频,youtube api)
                  Youtube iframe api not triggering onYouTubeIframeAPIReady(Youtube iframe api 未触发 onYouTubeIframeAPIReady)
                  How can I stop a video with Javascript in Youtube?(如何在 Youtube 中停止使用 Javascript 的视频?)
                  How to call Greasemonkey#39;s GM_ functions from code that must run in the target page scope?(如何从必须在目标页面范围内运行的代码中调用 Greasemonkey 的 GM_ 函数?)
                  How do you mute an embedded Youtube player?(如何使嵌入式 Youtube 播放器静音?)
                  How to get number of video views with YouTube API?(如何使用 YouTube API 获取视频观看次数?)

                  • <bdo id='eyk5H'></bdo><ul id='eyk5H'></ul>

                    <small id='eyk5H'></small><noframes id='eyk5H'>

                    <legend id='eyk5H'><style id='eyk5H'><dir id='eyk5H'><q id='eyk5H'></q></dir></style></legend>
                    • <tfoot id='eyk5H'></tfoot>

                            <tbody id='eyk5H'></tbody>
                            <i id='eyk5H'><tr id='eyk5H'><dt id='eyk5H'><q id='eyk5H'><span id='eyk5H'><b id='eyk5H'><form id='eyk5H'><ins id='eyk5H'></ins><ul id='eyk5H'></ul><sub id='eyk5H'></sub></form><legend id='eyk5H'></legend><bdo id='eyk5H'><pre id='eyk5H'><center id='eyk5H'></center></pre></bdo></b><th id='eyk5H'></th></span></q></dt></tr></i><div id='eyk5H'><tfoot id='eyk5H'></tfoot><dl id='eyk5H'><fieldset id='eyk5H'></fieldset></dl></div>