(编辑:jimmy 日期: 2024/11/14 浏览:2)
近日有人咨询Pushlet XMLAdapter 适配器的问题,我特留意了一下
到官方看了一下http://www.pushlets.com/,Development Roadmap中最后面说到了这个问题,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
这里必须说一下:
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
注意三点:
1:版本2.0.2
2:模式pull
3:格式xml-strict
4:文件ajax-pushlet-client.js
其实Pushlet官方也是有示例的
demos - Pushlets - AJAX
点击后运行可以看到,服务端返回的内容为,请结合上面4点看:
p_event=join-listen-ack
p_mode=pull
p_time=1380021729
p_id=qabynopuvu
p_format=xml-strict
p_sid=vyrel
然后打开页面源码看,其引用的文件:
<script type="text/javascript" src="/UploadFiles/2021-04-02/ajax-pushlet-client.js">
如果打开ajax-pushlet-client.js看一下,可以看到:
NV_P_FORMAT: 'p_format=xml-strict'
也就是说默认就是xml-strict
所以,参考此示例,就可以组织自己XMLHttpRequest适配下的应用了
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。