首页 > 代码库 > How to make an HTTP request

How to make an HTTP request

https://developer.mozilla.org/en-US/docs/AJAX/Getting_Started

In order to make an HTTP request to the server using JavaScript, you need an instance of a class that provides this functionality. This is where XMLHttpRequest comes in. Such a class was originally introduced in Internet Explorer as an ActiveX object called XMLHTTP. Then, Mozilla, Safari and other browsers followed, implementing an XMLHttpRequest class that supports the methods and properties of Microsoft‘s original ActiveX object. Meanwhile Microsoft has implemented XMLHttpRequest as well.

为了用JavaScript向服务器发送一个HTTP请求, 需要一个具备这种功能的类实例. 这样的类首先由Internet Explorer以ActiveX对象引入, 被称为XMLHTTP. 后来Mozilla, Safari 和其他浏览器纷纷仿效, 提供了XMLHttpRequest类,它支持微软的ActiveX对象所提供的方法和属性.

 

 

<script type="text/javascript"><!--    if(window.XMLHttpRequest){        httpRequest = new XMLHttpRequest();    } else if (window.ActiveObject)    {        httpRequest = new ActiveObject("Microsoft.XMLHTTP");    }//--></script>

 

How to make an HTTP request