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

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

    <small id='23pBx'></small><noframes id='23pBx'>

      • <bdo id='23pBx'></bdo><ul id='23pBx'></ul>

      <legend id='23pBx'><style id='23pBx'><dir id='23pBx'><q id='23pBx'></q></dir></style></legend><tfoot id='23pBx'></tfoot>

        在 AJAX 中處理增量服務器響應(在 JavaScript 中)

        Dealing with incremental server response in AJAX (in JavaScript)(在 AJAX 中處理增量服務器響應(在 JavaScript 中))

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

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

                <tbody id='yCJpo'></tbody>

              • <small id='yCJpo'></small><noframes id='yCJpo'>

                  <tfoot id='yCJpo'></tfoot>
                  本文介紹了在 AJAX 中處理增量服務器響應(在 JavaScript 中)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我有基于服務器響應更新頁面的 AJAX 應用程序.AJAX服務器響應所基于的命令需要很長時間才能生成完整的響應,但是一旦計算出來它就會發送部分信息.此部分響應/部分信息以突發"形式發送,并且每個突發的時間和大小是不可預測的.將命令輸出流式傳輸到 Web 瀏覽器(到 AJAX 請求)的 CGI 腳本(在 Perl 中)已打開自動刷新.

                  I have AJAX app which updates page based on server response. The command that AJAX server response is based on takes long time to generate full response, but it sends partial information as soon as it is calculated. This partial response / partial info is send in "burst", and time and size of each burst is unpredictable. CGI script (in Perl) that streams command output to web browser (to AJAX request) has autoflush turned on.

                  服務器響應基于外部命令的輸出.'time cmd >/dev/null' 平均給出大約 10.0 秒,'time cmd | head >/dev/null' 給出不到 0.1 秒(例如數據).所有數據都是單次調用此外部命令的結果.

                  The server response is based on output of external command. While 'time cmd > /dev/null" gives around 10.0 seconds on average, 'time cmd | head > /dev/null' gives less than 0.1 seconds (for example data). All data is result of single call to this external command.

                  情況如下(ASCII-藝術圖如下):

                   client |     | server
                  ---------     ---------
                  
                  request -
                            
                             
                              
                               ->
                  
                               /- response
                              /      .
                             /       .
                            /  /-    .
                         <-/  /      . 
                             /       .
                            /  /-  [end]
                         <-/  /
                             /
                            /
                         <-/
                  

                  我有幾個關于這個問題的問題.

                  I have a few questions about this problem.

                  注意:服務器端在 Perl 中作為 CGI 腳本完成,我更希望看到(也)解決方案,而不使用像 jQuery 這樣的 JavaScript 庫/框架.

                  Note: server side is done as CGI script in Perl, and I would prefer to see (also) solution without using JavaScript library / framework like jQuery.

                  • AJAX 應用服務器端使用的命令輸出是基于行的.每組線,以一種定義的線開始,以另一種線結束,由獨立且不可更改的數據組成.我應該只是將來自命令的響應流式傳輸為text/plain"并在客戶端用 JavaScript 進行處理,還是應該在服務器上預處理數據,并使用application/json"mimetype 將整個數據塊作為 JSON 發送?

                  • The output of command used by server side of AJAX app is line based. Each group of lines, beginning with one defined kind of line, and ending with other kind of line, consist of independend and unchangeable data. Should I just stream response from a command as 'text/plain' and do processing in JavaScript on client side, or should I pre-process data on server, and send whole chunks of data as JSON using 'application/json' mimetype?

                  可能會發生服務器一次發送的大量數據之后很快就會有另一塊數據的情況.如何處理 onreadystatechange 處理程序被調用而先前的調用沒有完成工作的情況?我應該使用全局變量作為信號量,還是將狀態變量作為處理程序參數傳遞(好吧,使用 xhr.onreadystatechange = function() { handleRequest(xhr, state) })?

                  It might happen that large chunk of data send at once by server is followed soon by another chunk of data. How to deal with situation when onreadystatechange handler is invoked while previous invocation didn't finished work? Should I use global variable as semaphore, or pass state variable as handler parameter (well, use xhr.onreadystatechange = function() { handleRequest(xhr, state) })?

                  我應該使用text/plain"還是application/json",或者可能是multipart/x0mixed-replace"?注意:這個應用程序應該可以在(幾乎)任何瀏覽器中運行.

                  Should I use 'text/plain' or 'application/json', or perhaps 'multipart/x0mixed-replace' for this? Note: this app should work in (alomst) any browser.

                  如何處理僅在收到完整響應后才調用 onReadyStateChange 的網絡瀏覽器(JavaScript 引擎)(所以我看不到 xhr.readyState == 3 即部分響應不止一次)?好吧,除了使用一些 JavaScript 框架.

                  How to deal with web browser (JavaScript engines) which invoke onReadyStateChange only after receiving complete response (so I don't see xhr.readyState == 3 i.e. partial response more than once)? Well, beside using some JavaScript framework.

                  如何處理不完整的響應(在這種情況下意味著不完整的行).

                  How to deal with incomplete responses (which in this situation mean incomplete lines).

                  我應該發送響應結束標記,還是依靠計數器來檢查我們是否收到了所有數據,或者我可以簡單地依靠檢測 xhr.readyState == 4?

                  Should I send end of response marker, or rely on counter to check if we received all data, or can I simply rely on detecting xhr.readyState == 4?

                  即使是部分回應也會有所幫助.

                  Even partial response would be helpful.

                  推薦答案

                  我認為 Comet 是您的解決方案所需的一部分.您還可以(如果我沒記錯的話)簽出 Bayeux Protocol,它是由 Dojo 基金會實施.整個事情還是很新的(盡管其中一些可能在第一個 HTML5 實現中是可能的).

                  I think Comet is part of what you need for your solution. You can additionally (if I got that right) checkout the Bayeux Protocol which was implemented by the Dojo Foundation. The whole thing is still very new (though some of it might be possible with the first HTML5 implementations).

                  除此之外,您可能還必須實施輪詢方法.另一個問題是,客戶端 JavaScript 解釋器可以處理多少數據.您是否有可能以某種方式分頁"您的數據,這樣您就不會遇到請求處理仍在處理而另一個響應已經到來的問題?

                  Besides that you would probably have to implement the polling approach. The other question is, how much data the client side JavaScript interpreter can handle. Is there any possibility for you to somehow "page" your data so that you won't have the problem of request handling still processing while aother response comes in already?

                  這篇關于在 AJAX 中處理增量服務器響應(在 JavaScript 中)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調用 abort (jQuery) 之后,瀏覽器也會等待 ajax 調用完成)
                  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屋-程序員軟件開發技術分
                  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 部分內容)
                    <legend id='HyypE'><style id='HyypE'><dir id='HyypE'><q id='HyypE'></q></dir></style></legend>

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

                            <tbody id='HyypE'></tbody>

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

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

                          • 主站蜘蛛池模板: a爱视频| 91在线一区二区三区 | 国产精品中文在线 | www日| 黄色综合| 欧美三级在线 | 中文字幕日本一区二区 | 91久久伊人 | 国产精品视频一区二区三区四蜜臂 | 在线观看特色大片免费网站 | 夜夜爽99久久国产综合精品女不卡 | 日韩一区二区免费视频 | 亚洲精品9999 | 国产一区二区在线播放 | 69性欧美高清影院 | www.亚洲.com| 国产美女一区二区三区 | 欧美日韩视频网站 | 久久精品日产第一区二区三区 | 黄色毛片一级 | 蜜桃视频在线观看免费视频网站www | 在线亚州 | 久久亚洲视频 | 日本精品视频 | 国产精品久久久久久久7电影 | 成人综合一区 | 视频二区国产 | 天天拍天天射 | 欧美综合在线观看 | 精品日韩电影 | 91精品国产综合久久婷婷香蕉 | 中文字幕在线一区二区三区 | 国产成人久久精品一区二区三区 | 亚洲一区av| 成人免费一区二区三区牛牛 | 欧美日韩国产高清 | 1区2区视频 | 在线免费观看毛片 | 91精品国产欧美一区二区成人 | 久久精品伊人 | 97超碰免费 |