AJAX簡歷系統(tǒng)附j(luò)s文件
更新時間:2007年08月16日 13:13:16 作者:
復制代碼 代碼如下:
/**********************************************
* @author skyz
* @function javascript client ajax dealwith
* @datetime 2006-3-20
**********************************************
* Function: Create a httpRequest object
**********************************************/
function HttpRequest(){
this._httpRequest=null; //HttpRequest request object
this._callBack=null; //Call back function
this._domResult=true; //Result if dom object or text string
this._requestData=null; //Request data
this._requestResult=null; //HttpRequest result
this._stateString=null; //Current request state string
this._error=false; //Current if have error
this._callBackPara=null; //Current callback function parama
//internal method for get HttpRequestObject
this.init=function(){
//Judge if Not IE
if(window.XMLHttpRequest){
this._httpRequest=new XMLHttpRequest();
//Set request mime is text/xml
if(this._httpRequest.overrideMimeType){
this._httpRequest.overrideMimeType('text/xml');
}
}else if(window.ActiveXObject){
try{
this._httpRequest=new ActiveXObject("Msxml2.XMLHTTP");
}catch(ex){
try{
this._httpRequest=new ActiveXObject("Microsoft.XMLHTTP");
}catch(ex){
this._setMessage(ex,true);
return;
}
}
// this._httpRequest.setrequestheader("Content-Type","text/xml;charset=gb2312");
}
//Judge HttpRequest object create successful
if(!this._httpRequest){
this._setMessage("XMLHttpRequest 對象創(chuàng)建失敗!請重試......",true);
return;
}
}
/*
* Function: Set the request header
* namePar:request's header name
* valuePar:request's header value
*/
this.doSetRequestHeader=function(namePar,valuePar){
if(this._error){
return;
}
this._httpRequest.setRequestHeader(namePar,valuePar);
}
/*
* Function: Set the request data
* dataPar:request's send data;
*/
this.doSetRequestData=function(dataPar){
if(this._error){
return;
}
this._requestData=dataPar;
}
/*
*Function get RequestHttp Object
*/
this._getRequestObj=function(){
if(this._error){
return;
}
return this._httpRequest;
}
/*
* Function:Set Callback function para
*/
this.doSetCallBack=function(callBack,paraData){
this._callBack=(callBack)?callBack:null;
this._callBackPara=(paraData)?paraData:null;
};
/*
* Function: Get current stateString
*/
this.doGetState=function(){
return this._stateString;
}
/*
* Function: get current Error
*/
this.doGetError=function(){
return this._error;
}
/*
*
*/
this.doCallBack=function(){
this._callBack(this._requestResult,this._callBackPara);
}
/*
* Function: Send the request
* urlPar: request's url path
* [methodPar]:request's method
* [domPar]: request's result is dom or string
*/
this.doSendResuest=function(urlPar,methodPar,obj,domPar,asyPar){
if(obj._error){
return;
}
methodPar=((methodPar)?methodPar:"GET");
asyPar=((asyPar)?asyPar:true);
this._domResult=(domPar)?domPar:obj._domResult;
try{
var a=this._getRequestObj();
a.onreadystatechange=function(){
if(obj._error){
return;
}
var readyStateTmp=a.readyState;
if(readyStateTmp==0){
obj._setMessage("未初始化!");
}else if(readyStateTmp==1){
obj._setMessage("正在讀取中......");
}else if(readyStateTmp==2){
obj._setMessage("已經(jīng)讀取過!");
}else if(readyStateTmp==3){
obj._setMessage("正在逐個切換......");
}else if(readyStateTmp==4){
var statusTmp=a.status;
if(statusTmp==404){
obj._setMessage("未找到請求頁面!",true);
}else if(window.location.href.indexOf("http")==-1 || statusTmp==200){
obj._setMessage("完成!");
if(this._domResult && window.XMLHttpRequest){
obj._requestResult=a.responseXml;
}else{
obj._requestResult=a.responseText;
}
if(obj._callBack){
obj.doCallBack();
}
}else{
obj._setMessage("未知錯誤!");
}
}else{
obj._setMessage("未知錯誤!");
}
}
a.open(methodPar,urlPar,asyPar);
// a.setRequestHeader("If-Modified-Since","0");
a.send(obj._requestData);
}catch(ex){
obj._setMessage(ex,true);
}
}
/*
* Function: Deal exception error
* exPar:error string
*/
this._setMessage=function(exPar,mark){
this._stateString=exPar.toString();
this._error=(mark)?mark:false;
}
}
本地下載
相關(guān)文章
通過Ajax兩種方式講解Struts2接收數(shù)組表單的方法
使用struts2表單傳值,可以傳一個或者是作為一個對象的各個屬性傳,都非常靈活便捷。但是如果我們需要傳一個數(shù)組并希望struts正確接收,該怎么處理呢?接下來,通過本文給大家介紹通過Ajax兩種方式講解Struts2接收數(shù)組表單的方法,需要的朋友可以參考下2015-10-10
Ajax讀取數(shù)據(jù)到表格的實現(xiàn)代碼
前兩篇我們講了 ajax開始的準備 與及如何使用ajax技術(shù)進行簡單的數(shù)據(jù)讀?。?/div> 2010-10-10
jQuery AJAX實現(xiàn)調(diào)用頁面后臺方法
這篇文章主要為大家詳細介紹了jQuery AJAX實現(xiàn)調(diào)用頁面后臺方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下2016-05-05
AJAX+Servlet實現(xiàn)的數(shù)據(jù)處理顯示功能示例
這篇文章主要介紹了AJAX+Servlet實現(xiàn)的數(shù)據(jù)處理顯示功能,結(jié)合實例形式分析了前臺ajax與后臺Servlet生成隨機數(shù)顯示的相關(guān)交互操作技巧,需要的朋友可以參考下2018-06-06
ajax智能提示+textbox動態(tài)生成下拉框示例代碼
ajax智能提示+textbox動態(tài)生成下拉框,下面有個不錯的示例,感興趣的朋友可以參考下,希望對大家有所幫助2013-12-12
配置Chrome支持本地(file協(xié)議)的AJAX請求
這篇文章主要為大家詳細介紹了配置Chrome支持本地(file協(xié)議)的AJAX請求 ,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-06-06
如何實現(xiàn)ajax延時發(fā)送在空閑之后去發(fā)送ajax請求
關(guān)鍵字搜索的功能,還是比較實用的,在實現(xiàn)過程中就需用到ajax延時發(fā)送,下面有個不錯的示例,有需要的朋友可以參考下2013-12-12
ajax獲得json對象數(shù)組 循環(huán)輸出數(shù)據(jù)的方法
今天小編就為大家分享一篇ajax獲得json對象數(shù)組 循環(huán)輸出數(shù)據(jù)的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-08-08最新評論

