Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement resume system with AJAX

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly shows you "AJAX how to achieve resume system", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to achieve resume system AJAX" this article.

The code is as follows:

/ *

* @ function javascript client ajax dealwith

*

* 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 object creation failed! please try again", 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 ("not initialized")

} else if (readyStateTmp==1) {

Obj._setMessage ("reading.")

} else if (readyStateTmp==2) {

Obj._setMessage ("read it!")

} else if (readyStateTmp==3) {

Obj._setMessage ("switching one by one")

} else if (readyStateTmp==4) {

Var statusTmp=a.status

If (statusTmp==404) {

Obj._setMessage ("request page not found!" , true)

} else if_ (window.location.href.indexOf ("http") = =-1 | | statusTmp==200) {

Obj._setMessage ("done!")

If (this._domResult & & window.XMLHttpRequest) {

Obj._requestResult=a.responseXml

} else {

Obj._requestResult=a.responseText

}

If (obj._callBack) {

Obj.doCallBack ()

}

} else {

Obj._setMessage (unknown error!)

}

} else {

Obj._setMessage (unknown error!)

}

}

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

}

}

The above is all the contents of the article "how to implement the resume system in AJAX". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report