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

What is the ajax asynchronous request server like?

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article introduces what the ajax asynchronous request server is like, the content is very detailed, interested friends can refer to, hope to be helpful to you.

I used to use jquery's integrated ajax, but now let's learn JavaScript's native ajax.

The following is a simple experiment in which ajax requests a xml content on the server.

Step 1: on the server, create a new xml and name it simpleAjax.xml. Enter the contents of the file as follows: This is the content of the simpleAjax.xml from server!

Step 2: on the server, create a new html, name it simpleAjax.html, and put it in the same directory as the simpleAjax.xml you just created.

SimpleAjax var xmlHttpRequest; / / XMLHttpRequest object name function sendRequest () {/ / send http request getXMLHttpRequest () / / get an operation xmlHttpRequest.open ("GET", "simpleAjax.xml") to be performed when the state changes from a XMLHttpRequest object to xmlHttpRequest xmlHttpRequest.onreadystatechange = stateChange; / / http; / / Connect xmlHttpRequest.send (null) / / send a request to the server (empty here)} function getXMLHttpRequest () {if (window.ActiveXObject) {/ / IE class xmlHttpRequest = new ActiveXObject ("Microsoft.XMLHTTP") } else if (window.XMLHttpRequest) {/ / Chrome class xmlHttpRequest = new XMLHttpRequest () }} function stateChange () {if (xmlHttpRequest.readyState = = 4 & & xmlHttpRequest.status = = 200) {/ / request completed and status OK alert (xmlHttpRequest.responseText) / / reaction}}

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