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

  • <legend id='yLssG'><style id='yLssG'><dir id='yLssG'><q id='yLssG'></q></dir></style></legend>

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

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

    2. <tfoot id='yLssG'></tfoot>

      1. “HTTP Streaming"的跨瀏覽器實(shí)現(xiàn)(推)AJAX 模式

        Cross-browser implementation of quot;HTTP Streamingquot; (push) AJAX pattern(“HTTP Streaming的跨瀏覽器實(shí)現(xiàn)(推)AJAX 模式)
        • <i id='Znejg'><tr id='Znejg'><dt id='Znejg'><q id='Znejg'><span id='Znejg'><b id='Znejg'><form id='Znejg'><ins id='Znejg'></ins><ul id='Znejg'></ul><sub id='Znejg'></sub></form><legend id='Znejg'></legend><bdo id='Znejg'><pre id='Znejg'><center id='Znejg'></center></pre></bdo></b><th id='Znejg'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Znejg'><tfoot id='Znejg'></tfoot><dl id='Znejg'><fieldset id='Znejg'></fieldset></dl></div>
            <tbody id='Znejg'></tbody>

        • <legend id='Znejg'><style id='Znejg'><dir id='Znejg'><q id='Znejg'></q></dir></style></legend>

        • <tfoot id='Znejg'></tfoot>

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

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

                1. 本文介紹了“HTTP Streaming"的跨瀏覽器實(shí)現(xiàn)(推)AJAX 模式的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  客戶端從服務(wù)器請(qǐng)求網(wǎng)頁.然后 Clent 要求進(jìn)行額外的計(jì)算;服務(wù)器執(zhí)行一系列計(jì)算并在部分結(jié)果可用時(shí)立即發(fā)送(文本格式,每行包含單獨(dú)的完整項(xiàng)目).客戶端使用服務(wù)器提供的信息更新網(wǎng)頁(使用 JavaScript 和 DOM).

                  Client request web page from server. Clent then requests for extra calculations to be done; server performs series of calculations and sends partial results as soon as they are available (text format, each line contains separate full item). Client updates web page (with JavaScript and DOM) using information provided by server.

                  這似乎適合 HTTP Streaming (當(dāng)前 版本)模式來自 Ajaxpatterns 站點(diǎn).

                  This seems to fit HTTP Streaming (current version) pattern from Ajaxpatterns site.

                  問題是如何以跨瀏覽器(與瀏覽器無關(guān))的方式進(jìn)行,最好不使用 JavaScript 框架,或使用一些輕量級(jí)框架,如 jQuery.

                  The question is how to do it in cross-browser (browser agnostic) way, preferably without using JavaScript frameworks, or using some lightweight framework like jQuery.

                  問題始于以跨瀏覽器方式生成 XMLHttpRequest,但我認(rèn)為主要是并非所有瀏覽器都能正確實(shí)現(xiàn) onreadystatechangefrom XMLHttpRequest;并非所有瀏覽器都會(huì)在每次服務(wù)器刷新時(shí)調(diào)用 onreadystatechange 事件(順便說一句.如何從 CGI 腳本(在 Perl 中)強(qiáng)制服務(wù)器刷新?).Ajaxpatterns 上的示例代碼通過使用計(jì)時(shí)器來處理這個(gè)問題;如果我檢測(cè)到來自 onreadystatechange 的部分響應(yīng),我應(yīng)該放棄計(jì)時(shí)器解決方案嗎?

                  The problem begins with generating XMLHttpRequest in cross-browser fashion, but I think the main item is that not all browsers implement correctly onreadystatechangefrom XMLHttpRequest; not all browsers call onreadystatechange event on each server flush (BTW. how to force server flush from within CGI script (in Perl)?). Example code on Ajaxpatterns deals with this by using timer; should I drop timer solution if I detect partial response from onreadystatechange?

                  添加于 2009 年 8 月 11 日

                  當(dāng)前解決方案:
                  我使用以下函數(shù)創(chuàng)建 XMLHttpRequest 對(duì)象:

                  Current solution:
                  I use the following function to create XMLHttpRequest object:

                  function createRequestObject() {
                          var ro;
                          if (window.XMLHttpRequest) {
                                  ro = new XMLHttpRequest();
                          } else {
                                  ro = new ActiveXObject("Microsoft.XMLHTTP");
                          }
                          if (!ro)
                                  debug("Couldn't start XMLHttpRequest object");
                          return ro;
                  }
                  

                  如果我要使用一些(最好是輕量級(jí)的)JavaScript 框架,比如 jQuery,如果用戶選擇不安裝 jQuery,我希望有備用.

                  If I were to use some (preferably light-weight) JavaScript framework like jQuery, I'd like to have fallback if user chooses not to install jQuery.

                  我使用下面的代碼來啟動(dòng) AJAX;使用 setInterval 是因?yàn)槟承g覽器僅在服務(wù)器關(guān)閉連接后(可能需要數(shù)十秒)才調(diào)用 onreadystatechange,而不是在服務(wù)器刷新數(shù)據(jù)時(shí)(大約每第二次或更頻繁).

                  I use the following code to start AJAX; setInterval is used because some browsers call onreadystatechange only after server closes connection (which can take as long as tens of seconds), and not as soon as server flushes data (around every second or more often).

                  function startProcess(dataUrl) {
                          http = createRequestObject();
                          http.open('get', dataUrl);
                          http.onreadystatechange = handleResponse;
                          http.send(null);
                  
                          pollTimer = setInterval(handleResponse, 1000);
                  }
                  

                  handleResponse 函數(shù)是最復(fù)雜的一個(gè),但它的草圖如下所示.可以做得更好嗎?如何使用一些輕量級(jí)的 JavaScript 框架(如 jQuery)來完成?

                  The handleResponse function is most complicated one, but the sketch of it looks like the following. Can it be done better? How it would be done using some lightweight JavaScript framework (like jQuery)?

                  function handleResponse() {
                      if (http.readyState != 4 && http.readyState != 3)
                          return;
                      if (http.readyState == 3 && http.status != 200)
                          return;
                      if (http.readyState == 4 && http.status != 200) {
                          clearInterval(pollTimer);
                          inProgress = false;
                      }
                      // In konqueror http.responseText is sometimes null here...
                      if (http.responseText === null)
                          return;
                  
                      while (prevDataLength != http.responseText.length) {
                          if (http.readyState == 4  && prevDataLength == http.responseText.length)
                              break;
                          prevDataLength = http.responseText.length;
                          var response = http.responseText.substring(nextLine);
                          var lines = response.split('
                  ');
                          nextLine = nextLine + response.lastIndexOf('
                  ') + 1;
                          if (response[response.length-1] != '
                  ')
                              lines.pop();
                  
                          for (var i = 0; i < lines.length; i++) {
                              // ...
                          }
                      }
                  
                      if (http.readyState == 4 && prevDataLength == http.responseText.length)
                          clearInterval(pollTimer);
                  
                      inProgress = false;
                  }
                  

                  推薦答案

                  實(shí)際上,您鏈接到的解決方案根本不是 AJAX.他們稱之為 HTTP 流,但它本質(zhì)上只是長(zhǎng)輪詢.

                  The solution you linked to is not AJAX at all, actually. They call it HTTP Streaming but it's essentially just long polling.

                  在他們鏈接到的示例中,您可以很容易地使用 firebug 自己查看.打開網(wǎng)絡(luò)面板 - 沒有 XHR 條目,但加載原始頁面只需 10 多秒.那是因?yàn)樗麄冊(cè)谀缓笫褂?PHP 來延遲 HTML 的輸出.這就是長(zhǎng)輪詢的本質(zhì)——HTTP 連接保持打開狀態(tài),周期性的 HTML 發(fā)回是 javascript 命令.

                  In the example they link to, you can see for yourself quite easily with firebug. Turn on the Net panel - there are no XHR entries, but it takes just a hair over 10 seconds to load the original page. That's because they're using PHP behind the scenes to delay the output of the HTML. This is the essence of long polling - the HTTP connection stays open, and the periodic HTML sent back is javascript commands.

                  不過,您可以選擇使用 setTimeout() 或 setInterval() 在客戶端完全進(jìn)行輪詢

                  You can opt to do the polling completely on the client side, though, with setTimeout() or setInterval()

                  一個(gè) jQuery 示例

                  A jQuery example

                  <script type="text/javascript">
                    $(document).ready(function()
                    {
                      var ajaxInterval = setInterval( function()
                      {
                        $.getJSON(
                          'some/servie/url.ext'
                          , { sample: "data" }
                          , function( response )
                            {
                              $('#output').append( response.whatever );          
                            }
                        );
                      }, 10000 );  
                    });
                  </script>
                  

                  這篇關(guān)于“HTTP Streaming"的跨瀏覽器實(shí)現(xiàn)(推)AJAX 模式的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調(diào)用 abort (jQuery) 之后,瀏覽器也會(huì)等待 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 無法加載,請(qǐng)求的資源上不存在“Access-Control-Allow-Origin標(biāo)頭) - IT屋-程序員軟件開發(fā)技術(shù)分
                  Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 請(qǐng)求是否有可能不遵循重定向 (301 302))
                  NETWORK_ERROR: XMLHttpRequest Exception 101(NETWORK_ERROR:XMLHttpRequest 異常 101)
                  XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分內(nèi)容)
                    <bdo id='977Wm'></bdo><ul id='977Wm'></ul>
                  • <legend id='977Wm'><style id='977Wm'><dir id='977Wm'><q id='977Wm'></q></dir></style></legend>
                      • <i id='977Wm'><tr id='977Wm'><dt id='977Wm'><q id='977Wm'><span id='977Wm'><b id='977Wm'><form id='977Wm'><ins id='977Wm'></ins><ul id='977Wm'></ul><sub id='977Wm'></sub></form><legend id='977Wm'></legend><bdo id='977Wm'><pre id='977Wm'><center id='977Wm'></center></pre></bdo></b><th id='977Wm'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='977Wm'><tfoot id='977Wm'></tfoot><dl id='977Wm'><fieldset id='977Wm'></fieldset></dl></div>
                          <tbody id='977Wm'></tbody>
                        <tfoot id='977Wm'></tfoot>

                          <small id='977Wm'></small><noframes id='977Wm'>

                          1. 主站蜘蛛池模板: 91综合网| 在线免费观看成年人视频 | 羞羞的视频网站 | 欧美成人手机在线 | 欧美日韩中文国产一区发布 | 日本精品一区二区三区视频 | 国产香蕉视频在线播放 | aaa精品 | 亚洲香蕉在线视频 | 久久综合久 | 久久亚洲一区二区 | 亚洲在线 | 欧美综合网 | 国产特级毛片aaaaaa | 日韩成人影院 | 精品国产乱码久久久久久蜜柚 | 欧美精品国产一区二区 | 日韩精品一区二区在线 | 免费黄色片视频 | 天天躁日日躁狠狠的躁天龙影院 | 国产91丝袜在线熟 | 超碰精品在线 | 日韩在线播放av | 在线看成人av | 91精品国产美女在线观看 | 久久久久久久久久一区 | 久久精品免费 | 亚洲一级毛片 | 粉嫩一区二区三区国产精品 | 欧美久久视频 | 久久精品在线 | 日本在线视频中文字幕 | 美女拍拍拍网站 | 黑人精品欧美一区二区蜜桃 | 日韩精品一二三 | 超碰免费在线 | 本地毛片 | 亚洲成人免费 | 狠狠操狠狠 | 精品久久久久久亚洲精品 | 日韩中文字幕 |