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>
时间: 2024-08-01 11:10:32

How to make an HTTP request的相关文章

HTTP 400 错误 - 请求无效 (Bad request)

在ajax请求后台数据时有时会报 HTTP 400 错误 - 请求无效 (Bad request);出现这个请求无效报错说明请求没有进入到后台服务里: 原因:1)前端提交数据的字段名称或者是字段类型和后台的实体类不一致,导致无法封装: 2)前端提交的到后台的数据应该是json字符串类型,而前端没有将对象转化为字符串类型: 解决方案: 1)对照字段名称,类型保证一致性 2)使用stringify将前端传递的对象转化为字符串    data: JSON.stringify(param)  ;

Spring Cloud ZooKeeper集成Feign的坑2,服务调用了一次后第二次调用就变成了500,错误:Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is com.n

错误如下: 2017-09-19 15:05:24.659 INFO 9986 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.spring[email protected]56528192: startup date [Tue Sep 19 15:05:24 CST 2017]; root of context hierarchy 2017-09-19 15:05:24.858 INFO 9986 --

ASP.NET取得Request URL的各个部分

ASP.NET取得Request URL的各个部分  网址:http://localhost:1897/News/Press/Content.aspx/123?id=1#toc Request.ApplicationPath / Request.PhysicalPath D:\Projects\Solution\web\News\Press\Content.aspx System.IO.Path.GetDirectoryName(Request.PhysicalPath) D:\Projects

Webform 内置对象 Response对象、Request对象,QueryString

Request对象:获取请求Request["key"]来获取传递过来的值 QueryString:地址栏数据传递 ?key=value&key=value注意事项:不需要保密的东西可以传不要传过长东西,因为长度有限,过长会造成数据丢失 Response对象:响应请求Response.Write("<script>alert('添加成功!')</script>");Response.Redirect("Default.asp

译-BMC Remedy Action Request System权限控制概述

原文链接:Access control overview 说明: BMC Remedy Action Request System是BMC ITSM产品平台,简称AR 或者Remedy,可实现基于ITIL标准的整个IT管理流程的实施定制.该平台可实现多种权限级别的管理,包括人员.组.角色,以及表.字段.行级别等.本文可以用作其他对权限要求比较精细的系统参考. 为了便于理解,部分名词翻译如下: Server:服务器Form (or table):表单Field (or column):字段Acti

request.setAttribute(&quot;username&quot;, username);//一定要保存,OGNL才能获取${username}

public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("utf-8"); String username= request.getParameter("username"); request.setAttribute("use

AWS CloudFront CDN直接全站加速折腾记The request could not be satisfied. Bad request

ERROR The request could not be satisfied. Bad request. Generated by cloudfront (CloudFront) Request ID: JC3i8piJpjRbuP81MNhSKPxt5KWirIInynZgwFJ9EYKuysjS5A_AnQ== 上面这个问题害我着急的很啊.在这里谢谢远在东京的小伙伴在百忙之中帮我分析解决这个问题. 使用AWS也有段时间了,基本常用的服务都用了,还有很多服务没用上,正在慢慢摸索中..说实话

web初学之request,session与application

request (1)request的setAttribute()与getAttribute()方法一般都是成对出现,首先通过setAttribute()方法设置属性与属性值,然后通过getAttribute()方法根据属性获取到与该属性对应的对象值.setAttribute()与getAttribute()方法都是在服务器端内部执行,客户端并不清楚.(注意:getAttribute()之后需要进行向下类型转换,将属性值转换为真正的对象) (2)request的getParameter()方法是

Request和Response详解

转自:http://zhidao.baidu.com/link?url=8BI0cjlcFdBSJKHTZlpo874eqtbTJoZfrh3miQgM_05RvSER8skPiBc1wSPZtXT8OGGCHfVXFAzAosa6E5HBl_ 内置对象request:请求对象request.getParameter("名字") 获得客户端输入的信息***************request.getParameterValues("名字") 获得客户端输入的一组信

The JSON request was too large to be deserialized

The JSON request was too large to be deserialized 这个问题出现的场景并不是很多,当你向服务端异步(ajax)post数据非常大的情况下(比如做权限管理的时候给某个角色分配权限那么就可能会出现,我所遇到的就是该角色大概200个模块每个模块平均2个功能----那么发送到服务端action的将是一个有着400个对象的数组) 之前我们向服务端异步post数组可能需要使用 1 $.ajax({ 2 type: 'POST', 3 url: '/system