AJAX creates XMLHttpRequest object

XMLHttpRequest is the foundation of AJAX.

XMLHttpRequest object

All modern browsers support the XMLHttpRequest object (IE5 and IE6 use ActiveXObject).

XMLHttpRequest is used to exchange data with the server in the background. This means that certain parts of the webpage can be updated without reloading the entire webpage.

Create an XMLHttpRequest object

All modern browsers (IE7+, Firefox, Chrome, Safari, and Opera) have built-in XMLHttpRequest objects.

Syntax to create an XMLHttpRequest object:

variable=new XMLHttpRequest();

Old versions of Internet Explorer (IE5 and IE6) use ActiveX objects:

variable=new ActiveXObject("Microsoft.XMLHTTP");

In order to deal with all modern browsers, including IE5 and IE6, please check whether the browser supports the XMLHttpRequest object. If supported, create an XMLHttpRequest object. If not, create ActiveXObject:

Tag: front-end training

Guess you like

Origin blog.csdn.net/msjhw_com/article/details/109090979