0 Star 0 Fork 1

洞悉/gjs

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
comt.ws.js 1.17 KB
一键复制 编辑 原始数据 按行查看 历史
洞悉 提交于 2016-09-06 18:04 +08:00 . add
/**
* 用长连接轮询和websocket封装
*/
(function(){
function ajax(ops){
ops.data=ops.data || '';
ops.succ=ops.succ || function(){};
ops.fail=ops.fail || function(){};
ops.pending=ops.pending || function(){};
ops.start=ops.start || function(){};
var xhr = new XMLHttpRequest();
xhr.onreadystatechange=function(){
if(xhr.readyState==4){
if(xhr.status==200){
ops.succ(xhr.responseText);
}else{
ops.fail(xhr);
}
}else{
ops.pend(xhr);
}
}
//xhr.timeout = ops.timeout || 60;
xhr.open('post',ops.url,true);
ops.start();
xhr.send(ops.data);
return xhr;
}
})();
(function(){
var ws,reqed,url;
if(window.WebSocket){
ws = window.WebSocket(url);
}
function comt(url){
this.url = url;
this.onopen=function(){};
this.onclose=function(){};
this.onmessage=function(){};
this.init();
}
comt.prototype.init=function(){
}
comt.prototype.send=function(){
};
})();
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/jitog/gjs.git
git@gitee.com:jitog/gjs.git
jitog
gjs
gjs
master

搜索帮助