仿jquery ajax,不過功能沒那麼多。貼**
--------------------------------------分割線------------------------------------------
//myxhr物件
var myxhr = function
(config),
"success":function
(), "error":function
() };
//合併配置項
var mergeconfig = this.config = this.extend(this
.config, defaultconfig);
var xhr = this
.createxhr();
//處理邏輯
var postdata = null
;
var url =mergeconfig.options.url;
if(mergeconfig.options.method == "post")
postdata =formdata;
}else
xhr.open(mergeconfig.options.method, url, mergeconfig.options.async);
xhr.onreadystatechange = function
()else}};
xhr.send(postdata);
//超時報錯
xhr.ontimeout = function()}
/**以下為公共方法*
*///
extend方法,與$.extend()相同
myxhr.prototype.extend = function
(p1, p2);//
返回值for(var item in
p2)else
else}}
return
p; })(p1,p2);
return
p;s};
//建立xhr
/**支援xhr物件和activex物件*
*/myxhr.prototype.createxhr = function
()else
if(typeof activexobject != "undefined")
catch
(ex)}}
return
newactivexobject(arguments.callee.activexstring);
}else}//
處理url
myxhr.prototype.dealurl = function
(url)
var domain = url.substring(0, index);
var pars = url.slice(index+1);
var arrs = pars.split('&');
var newurl =domain;
for(var item in
arrs)
newurl += (split + encodeuricomponent(arr[0]) + "=" + encodeuricomponent(arr[1]));
}return
newurl;
}
使用方法:
var xhr = newmyxhr(,
"success":function
(data),
"error":function
() });
重複造輪子 kmq
第一章 kafka基礎概念 第二章 kafka集群部署實踐 第三章 重複造輪子 kmq 基於記憶體queue實現生產和消費api 1 建立記憶體blockingqueue,作為底層訊息儲存 2 定義topic,支援多個topic 3 定義producer,支援send訊息 4 定義consumer,...
如何避免重複造輪子問題
人家已經總結出的系統的經驗知識,可是因為不知道它的存在或沒有找到,摸索幾年後,才發現自己走了遠路。如企業管理中的 六脈神劍 阿里巴巴的績效考核體系至少有80 在所有企業中是共通的。可見 a.自己要做什麼輪子?b.是否有現成的 或近似的輪子。記住這兩個問題。第二個例子是軟體開發,現成的輪子有 a.開源...
造輪子之常用函式的封裝
常用函式的封裝 時間操作常用函式 幫助類定義 字串操作封裝class yr common 實現string yr common trim const string sstr,const string s,bool bchar string yr common trimleft const strin...