AJAX - XMLHttpRequest Object

Create XMLHttpRequest object

XMLHttpRequest is the foundation of AJAX.

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

Note: IE5 / IE6 requires ActiveRequest object.

Send a request to the server

xmlhttp.open("GET","ajax_info.txt",true);

xmlhttp.send();

GET or POST?

Compared with POST, GET easier and faster, and can be used in most cases.

However, in the following cases, please use the POST request:

  • Can not use the cache files (files or update the database on the server)
  • Sending large amounts of data (POST not limit the amount of data) to the server
  • When sending the user input contains unknown character, POST is more stable and more reliable than the GET

Guess you like

Origin www.cnblogs.com/1016391912pm/p/11846477.html