JS pushlet XMLAdapter適配器用法案例解析
近日有人咨詢Pushlet XMLAdapter 適配器的問題,我特留意了一下
到官方看了一下http://www.pushlets.com/,Development Roadmap中最后面說(shuō)到了這個(gè)問題,AJAX (XMLHttpRequest) Support使用AJAX (XMLHttpRequest)的好處就是:
cleaner and thinner client-side lib no issues with 'busy' indicators pure XML data exchange (i.s.o. JavaScript callbacks)
英文不好就不再翻譯了
但是要注意的是:
no universal support for XMLHttpRequest on all browsers (can be emulated in various ways though) event streaming can only be emulated in Mozilla (using readystate == 3 and accessing partly received content) from this follows that only pull-mode can be conducted
這里必須說(shuō)一下:
1不是所有瀏覽器都支持
2流模式只是在火狐上支持
3只能使用PULL模式
然后:
Done. Since version 2.0.2 Pushlets support AJAX in 'pull'-mode with format='xml-strict'. An AJAX JS client library (ajax-pushlet-client.js) is available
注意三點(diǎn):
1:版本2.0.2
2:模式pull
3:格式xml-strict
4:文件ajax-pushlet-client.js
其實(shí)Pushlet官方也是有示例的
demos - Pushlets - AJAX
點(diǎn)擊后運(yùn)行可以看到,服務(wù)端返回的內(nèi)容為,請(qǐng)結(jié)合上面4點(diǎn)看:
p_event=join-listen-ack p_mode=pull p_time=1380021729 p_id=qabynopuvu p_format=xml-strict p_sid=vyrel
然后打開頁(yè)面源碼看,其引用的文件:
<script type='text/javascript' src='http://www.hdgsjgj.cn/lib/ajax-pushlet-client.js'></script>
如果打開ajax-pushlet-client.js看一下,可以看到:
NV_P_FORMAT: ’p_format=xml-strict’
也就是說(shuō)默認(rèn)就是xml-strict
所以,參考此示例,就可以組織自己XMLHttpRequest適配下的應(yīng)用了
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. 存儲(chǔ)于xml中需要的HTML轉(zhuǎn)義代碼2. python 浮點(diǎn)數(shù)四舍五入需要注意的地方3. Java GZip 基于內(nèi)存實(shí)現(xiàn)壓縮和解壓的方法4. python開發(fā)一款翻譯工具5. 利用CSS制作3D動(dòng)畫6. jsp+servlet簡(jiǎn)單實(shí)現(xiàn)上傳文件功能(保存目錄改進(jìn))7. Springboot 全局日期格式化處理的實(shí)現(xiàn)8. 完美解決vue 中多個(gè)echarts圖表自適應(yīng)的問題9. SpringBoot+TestNG單元測(cè)試的實(shí)現(xiàn)10. PHP實(shí)現(xiàn)簡(jiǎn)單線性回歸之?dāng)?shù)學(xué)庫(kù)的重要性
