In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
Editor to share with you the creation of XMLHTTP objects in AJAX, to distinguish which functions are commonly used in IE,Mozilla browsers, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!
AJAX commonly used functions to create XMLHTTP objects, to distinguish the functions of IE,Mozilla browsers. There are many functions on the Internet to create XMLHTTP objects and distinguish IE,Mozilla browsers. This is quite good, and you can use it directly.
The code is as follows:
Function getRequest () {
Http_request = false
If (window.XMLHttpRequest) {
/ / for browsers such as Mozilla, Netscape, Safari, create a XMLHttpRequest
Http_request = new XMLHttpRequest ()
If (http_request.overrideMimeType) {
/ / if the header of the server response is not text/xml, you can call other methods to modify the header
Http_request.overrideMimeType ('text/xml')
}
} else if (window.ActiveXObject) {
/ / for Internet Explorer browsers, create a XMLHttpRequest
Try {
Http_request = new ActiveXObject ("Msxml2.XMLHTTP")
} catch (e) {
Try {
Http_request = new ActiveXObject ("Microsoft.XMLHTTP")
} catch (e) {}
}
}
Return http_request
}
/ / obtain the responseText of Url
Function getResponseText (url)
{
Http_request=getRequest ()
Http_request.open ('GET', url, false)
Http_request.send (null)
If (http_request.readyState = = 4)
{
/ / receive a complete server response
If (http_request.status = = 200) {
/ / the value OK of the HTTP server response
Requestdoc = http_request.responseText
/ / write the string returned by the server to the area of the page where ID is message
}
Else {
Requestdoc = http_request.status
}
}
Return requestdoc
}
/ / obtain the responseXML of Url
Code snippet
Function getResponseText (url)
{
Http_request=getRequest ()
Http_request.open ('GET', url, false)
Http_request.send (null)
If (http_request.readyState = = 4)
{
/ / receive a complete server response
If (http_request.status = = 200) {
/ / the value OK of the HTTP server response
Requestdoc = http_request.responseXML
/ / write the string returned by the server to the area of the page where ID is message
}
Else {
Requestdoc = http_request.status
}
}
Return requestdoc
}
The above is all the content of the article "creating XMLHTTP objects in AJAX, distinguishing what are the common functions of IE,Mozilla browsers?" 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.
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.