Home >Web Front-end >JS Tutorial >How to quickly obtain Ajax communication objects

How to quickly obtain Ajax communication objects

亚连
亚连Original
2018-05-22 14:47:191224browse

Below I will bring you an article on how to quickly obtain Ajax communication objects. Let me share it with you now and give it as a reference for everyone.

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;
}

The above is what I compiled for everyone. I hope it will be helpful to everyone in the future.

Related articles:

The problem of passing array parameters by calling webservice in jQuery through ajax (graphic tutorial)

Use ajaxDetailed explanation of the method of passing arrays and receiving in the background

How to solve the problem of Ajax passing data with special characters

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn