In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "the usage of AJAX request class". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the usage of AJAX request class".
The code is as follows:
/ / AJAX class
Function AJAXRequest () {
Var xmlObj = false
Var CBfunc,ObjSelf
ObjSelf=this
Try {xmlObj=new XMLHttpRequest;}
Catch (e) {
Try {xmlObj=new ActiveXObject ("MSXML2.XMLHTTP");}
Catch (E2) {
Try {xmlObj=new ActiveXObject ("Microsoft.XMLHTTP");}
Catch (e3) {xmlObj=false;}
}
}
If (! xmlObj) return false
This.method= "POST"
This.url
This.async=true
This.content= ""
This.callback=function (cbobj) {return;}
This.send=function () {
If (! this.method | |! this.url | |! this.async) return false
XmlObj.open (this.method, this.url, this.async)
If (this.method== "POST") xmlObj.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded")
XmlObj.onreadystatechange=function () {
If (xmlObj.readyState==4) {
If (xmlObj.status==200) {
ObjSelf.callback (xmlObj)
}
}
}
If (this.method== "POST") xmlObj.send (this.content)
Else xmlObj.send (null)
}
}
AJAX request class
By HotHeart (warm-hearted)
Site: http://www.xujiwei.cn/
Blog: http://www.xujiwei.cn/blog/
Class name: AJAX
Creation method: var ajaxobj=new AJAX;, returns false if creation fails
Attribute: method-request method, string, POST or GET. Default is POST
Url-request URL, string, empty by default
Async-whether asynchronous. True is asynchronous, false is synchronous. Default is true.
Content-the content of the request. If the request method is POST, this property needs to be set. Default is empty.
Callback-callback function, that is, the function that is called when the response content is returned. By default, the callback function is returned directly. The callback function has a parameter of XMLHttpRequest object, that is, the callback function should be defined as follows: function mycallback (xmlobj)
Method: send ()-send a request with no parameters
An example:
Var ajaxobj=new AJAXRequest; / / create AJAX object
Ajaxobj.method= "GET"; / / set the request method to GET
Ajaxobj.url= "default.asp" / / URL is default.asp
/ / set the callback function and output the response content
Ajaxobj.callback=function (xmlobj) {
[xss_clean] (xmlobj.responseText)
}
Ajaxobj.send (); / / send the request
Thank you for reading, the above is the content of "the usage of AJAX request class". After the study of this article, I believe you have a deeper understanding of the usage of AJAX request class, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.