Home >Web Front-end >JS Tutorial >How to quickly obtain Ajax communication objects
This time I will show you how to quickly obtain Ajax communication objects, and what are the precautions for obtaining Ajax communication objects. The following is a practical case, let's take a look.
The examples are as follows:
function getXHR() { // 该方法用于获取Ajax通信对象 var xhr = null; if (window.XMLHttpRequest != null && window.XMLHttpRequest != undefined) { xhr = new XMLHttpRequest(); } else { / 兼容早期的IE浏览器 xhr = new ActiveXObject("Microsoft.XMLHTTP"); } return xhr; }
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the PHP Chinese website !
Recommended reading:
Use Ajax to upload Base64 format images during H5 development
##ajax implements paging query function
The above is the detailed content of How to quickly obtain Ajax communication objects. For more information, please follow other related articles on the PHP Chinese website!