久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

      <tfoot id='tGb4N'></tfoot>

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

      <i id='tGb4N'><tr id='tGb4N'><dt id='tGb4N'><q id='tGb4N'><span id='tGb4N'><b id='tGb4N'><form id='tGb4N'><ins id='tGb4N'></ins><ul id='tGb4N'></ul><sub id='tGb4N'></sub></form><legend id='tGb4N'></legend><bdo id='tGb4N'><pre id='tGb4N'><center id='tGb4N'></center></pre></bdo></b><th id='tGb4N'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='tGb4N'><tfoot id='tGb4N'></tfoot><dl id='tGb4N'><fieldset id='tGb4N'></fieldset></dl></div>
        • <bdo id='tGb4N'></bdo><ul id='tGb4N'></ul>
        <legend id='tGb4N'><style id='tGb4N'><dir id='tGb4N'><q id='tGb4N'></q></dir></style></legend>
      1. 循環(huán)中的 XMLHttpRequest

        XMLHttpRequest in for loop(循環(huán)中的 XMLHttpRequest)
          <bdo id='NSXgi'></bdo><ul id='NSXgi'></ul>

                <tfoot id='NSXgi'></tfoot>

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

                  <tbody id='NSXgi'></tbody>
              • <legend id='NSXgi'><style id='NSXgi'><dir id='NSXgi'><q id='NSXgi'></q></dir></style></legend>
                  <i id='NSXgi'><tr id='NSXgi'><dt id='NSXgi'><q id='NSXgi'><span id='NSXgi'><b id='NSXgi'><form id='NSXgi'><ins id='NSXgi'></ins><ul id='NSXgi'></ul><sub id='NSXgi'></sub></form><legend id='NSXgi'></legend><bdo id='NSXgi'><pre id='NSXgi'><center id='NSXgi'></center></pre></bdo></b><th id='NSXgi'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='NSXgi'><tfoot id='NSXgi'></tfoot><dl id='NSXgi'><fieldset id='NSXgi'></fieldset></dl></div>

                  本文介紹了循環(huán)中的 XMLHttpRequest的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在嘗試在 for 循環(huán)中發(fā)出多個服務器請求.我發(fā)現(xiàn) this question 并實施了建議的解決方案.但是它似乎不起作用.

                  I am trying to make several server requests inside a for loop. I found this question and implemented the suggested solution. However it doesn't seem to work.

                      for (var i = 1; i <= 10; i++)
                      {
                      (function(i) {
                      if(<some conditions>)
                      {
                      if (window.XMLHttpRequest) {
                          // code for IE7+, Firefox, Chrome, Opera, Safari
                          xmlhttp[i]=new XMLHttpRequest();
                        } else { // code for IE6, IE5
                          xmlhttp[i]=new ActiveXObject("Microsoft.XMLHTTP");
                        }
                        xmlhttp[i].onreadystatechange=function() {
                          if (xmlhttp[i].readyState==4 && xmlhttp[i].status==200) {
                            document.getElementById("preselection").innerHTML=xmlhttp[i].responseText;
                          }
                        }
                        xmlhttp[i].open("GET","getBuoys.php?q="+i,true);
                        xmlhttp[i].send();
                      }
                  })(i);
                  }
                  

                  如果我刪除 for 循環(huán)并將所有 xmlhttp[i] 更改為 xmlhttp,對于一個元素來說一切正常,但我無法發(fā)出多個請求.提前感謝您的任何建議.

                  If I remove the for loop and change all xmlhttp[i] to xmlhttp, everything works just fine for one element, but I can't make several requests. Thanks in advance for any suggestions.

                  推薦答案

                  試試下面的代碼片段

                  // JavaScript
                  window.onload = function(){
                  
                      var f = (function(){
                          var xhr = [], i;
                          for(i = 0; i < 3; i++){ //for loop
                              (function(i){
                                  xhr[i] = new XMLHttpRequest();
                                  url = "closure.php?data=" + i;
                                  xhr[i].open("GET", url, true);
                                  xhr[i].onreadystatechange = function(){
                                      if (xhr[i].readyState === 4 && xhr[i].status === 200){
                                          console.log('Response from request ' + i + ' [ ' + xhr[i].responseText + ']'); 
                                      }
                                  };
                                  xhr[i].send();
                              })(i);
                          }
                      })();
                  
                  };
                  
                  // PHP [closure.php]
                  echo "Hello Kitty -> " . $_GET["data"];
                  

                  回應

                  Response from request 0 [ Hello Kitty -> 0]
                  Response from request 1 [ Hello Kitty -> 1]
                  Response from request 2 [ Hello Kitty -> 2] 
                  

                  這篇關于循環(huán)中的 XMLHttpRequest的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調(diào)用 abort (jQuery) 之后,瀏覽器也會等待 ajax 調(diào)用完成)
                  JavaScript innerHTML is not working for IE?(JavaScript innerHTML 不適用于 IE?)
                  XMLHttpRequest cannot load, No #39;Access-Control-Allow-Origin#39; header is present on the requested resource(XMLHttpRequest 無法加載,請求的資源上不存在“Access-Control-Allow-Origin標頭) - IT屋-程序員軟件開發(fā)技術分
                  Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 請求是否有可能不遵循重定向 (301 302))
                  NETWORK_ERROR: XMLHttpRequest Exception 101(NETWORK_ERROR:XMLHttpRequest 異常 101)
                  XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分內(nèi)容)
                  <legend id='bYrYj'><style id='bYrYj'><dir id='bYrYj'><q id='bYrYj'></q></dir></style></legend>
                1. <small id='bYrYj'></small><noframes id='bYrYj'>

                  1. <tfoot id='bYrYj'></tfoot>
                      <i id='bYrYj'><tr id='bYrYj'><dt id='bYrYj'><q id='bYrYj'><span id='bYrYj'><b id='bYrYj'><form id='bYrYj'><ins id='bYrYj'></ins><ul id='bYrYj'></ul><sub id='bYrYj'></sub></form><legend id='bYrYj'></legend><bdo id='bYrYj'><pre id='bYrYj'><center id='bYrYj'></center></pre></bdo></b><th id='bYrYj'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='bYrYj'><tfoot id='bYrYj'></tfoot><dl id='bYrYj'><fieldset id='bYrYj'></fieldset></dl></div>
                        <tbody id='bYrYj'></tbody>

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

                          • 主站蜘蛛池模板: 中文字幕第二十页 | 韩日一区 | 毛片一级片 | 欧美一区二区三区在线观看 | 日产精品久久久一区二区福利 | 91免费版在线观看 | 欧美一级片在线观看 | 中文字幕精品视频 | 麻豆视频在线免费观看 | 99国产精品久久久久 | 亚洲自拍偷拍视频 | 成人免费视频网址 | 91色在线| 成人午夜影院 | 视频一区二区在线观看 | 色噜噜亚洲男人的天堂 | 日日人人| 91精品一区二区 | 久久久久久久一区二区三区 | 国产精品免费一区二区 | 日日操夜夜操天天操 | 中文字幕高清 | 欧美久久久久久久久 | 日韩精品一区二区不卡 | 国产a区 | a级大片免费观看 | 天堂色综合 | 亚洲一区二区精品视频 | 一区二区三区免费 | 成人国产精品色哟哟 | 中文字幕在线一区二区三区 | 在线成人免费视频 | 亚洲成人毛片 | 日韩电影免费在线观看中文字幕 | 国产精品成人一区二区三区夜夜夜 | 秋霞精品 | 亚洲午夜电影 | 一二三四av | 亚洲狠狠爱 | 日韩在线中文 | 一区二区三区在线播放 |