In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces the example analysis of XMLHttpRequest object in AJAX, which is very detailed and has certain reference value. Friends who are interested must finish it!
AJAX is a web page development technology for creating interactive web page applications, which is a collection of asynchronous Javascript and XML. Its core is the XMLHttpRequest object, which can partially update the web page without submitting the whole page to the server. It is a key technology of AJAX's Web application architecture.
Basic attributes:
Basic methods:
XMLHttpRequest five-step method:
First: create a XMLHttpRequest object
Second: register the callback function
Third: set the parameters that interact with the server
Fourth: set up the data sent to the server and start the interaction with the server
Fifth, judge whether the interaction with the server is completed, and whether the server returns the correct data.
HTML Code:
Var xmlhttp; function submit () {/ / 1, create XMLHttpRequest object if (window.XMLHttpRequest) {xmlhttp = new XMLHttpRequest (); if (xmlhttp.overrideMineType) {/ / modify the BUG of certain versions of mozillar browsers / / overwrite the header sent to the server, forcing text/xml as mime-type xmlhttp.overrideMineType ("text/xml") } else if (window.ActiveXObject) {/ / processing for IE browsers var activexName = ["MSXML2.XMLHTTP.6.0", "MSXML2.XMLHTTP.5.0", "MSXML2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Miscrosoft XMLHTTP"]; for (var I = 0; I < activexName.length; iTunes +) {try {xmlhttp=new ActiveXObject (activexName.length; name [I]) Break;} catch (e) {}} if (xmlhttp = = undefined | | xmlhttp = = null) {alert ("plug-in XMLHttpRequest object is not supported in the current browser, please change the browser"); return;} / / 2, register the callback function xmlhttp.onreadystatechange = callback; / / to get the current value var username = document.getElementById ("userName"). Value / / set string parameters and encode (for POST submission) var args = "username=" + encodeURIComponent (username); / / GET interaction / / 3, set parameters for interaction with server / / xmlhttp.open ("GET", "XMLHttpRequest.aspx?username=" + username, true) / / POST interaction / / 3, set parameters for interaction with the server / / use Post method not to worry about caching xmlhttp.open ("POST", "XMLHttpRequest.aspx?username=" + username, true); / / set the Content-Type type to inform the server that there are parameters xmlhttp.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded") in the entity / / 4. Set the data sent to the server and start the interaction with the server / / for GET submission / / xmlhttp.send (null); / / for POST submission xmlhttp.send (args) Function callback () {/ / 5, judge whether the interaction with the server side is completed, and judge whether the server side has correctly returned data if (xmlhttp.readyState = = 4) {/ / readyState=4 indicates that the interaction is completed if (xmlhttp.status = = 200) {/ / status=200 indicates that the receiving method of data / / plain text data is returned correctly var message = xmlhttp.responseText Var div = document.getElementById ("message"); div [XSS _ clean] = message;}
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.