博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
XDomainRequest object
阅读量:6173 次
发布时间:2019-06-21

本文共 3920 字,大约阅读时间需要 13 分钟。

The XDomainRequest object has these types of members:

Events

The XDomainRequest object has these events.

Event Description

Raised when there is an error that prevents the completion of the cross-domain request.

Raised when the object has been completely received from the server.

Raised when the browser starts receiving data from the server.

Raised when there is an error that prevents the completion of the request.

 

Methods

The XDomainRequest object has these methods.

Method Description

The abort method terminates a pending .

Cancels the current HTTP request.

Creates a connection with a domain's server.

Transmits a data string to the server for processing.

 

Properties

The XDomainRequest object has these properties.

Property Description

Returns a reference to the constructor of an object.

Gets the  property in the HTML request or response header.

Retrieves the response body as a string.

Gets or sets the time-out value.

 

Standards information

There are no standards that apply here.

Remarks

The XDomainRequest object is a safe, reliable, and lightweight data service that allows script on any document to anonymously connect to any server and exchange data. Developers can use the XDomainRequest object when cross-site security is not an issue.

Security Warning:   Cross-domain requests ("XDRs") are anonymous to protect user data. This means that servers cannot easily determine who is requesting data. To protect user privacy, respond with cross-domain data that is neither sensitive nor personally identifiable. To help prevent intranet data from being leaked to malicious Internet sites, we discourage intranet sites from making XDR data available.

Cross-domain requests require mutual consent between the document and the server. You can initiate a cross-domain request by creating an XDomainRequest (XDR) object with the  object, and opening a connection to a domain.

The document will request data from the domain's server by sending an Origin header with the value of the origin. It will only complete the connection if the server responds with an Access-Control-Allow-Origin header of either * or the exact URL of the requesting document. This behavior is part of the World Wide Web Consortium (W3C)'s Web Application Working Group's draft framework on client-side cross-domain communication that the  object integrates with.

For example, a server's Active Server Pages (ASP) page might include the following response header:

 
 
<% Response.AddHeader("Access-Control-Allow-Origin","*") %>

Cross domain requests can only be sent and received from a document to URLs in the following zones:

From Document \ To URL Intranet Trusted(Intranet) Trusted(Internet) Internet Restricted
Intranet Allow Allow Allow Allow Deny
Trusted(Intranet) Allow Allow Allow Allow Deny
Trusted(Internet) Deny Deny Allow Allow Deny
Internet Deny Deny Allow Allow Deny
Restricted Deny Deny Deny Deny Deny

 

The XDR protocol only works with the http:// and https:// protocols.

To use the XDR protocol, you first create an XDomainRequest object. Then you use the  method to establish a connection with a server. Once a connection is opened, the  method transmits data strings to the server for processing. For example:

 
 
// 1. Create XDR object: var xdr = new XDomainRequest(); // 2. Open connection with server using GET method:xdr.open("get", "http://www.contoso.com/xdr.aspx");// 3. Send string data to server:xdr.send();

Examples

The following example sends an empty message to a server of your choice. You can select a  value (default 10000 msec) when sending the request. When you click the Get button, the script creates aXDomainRequest, assigns event handlers, and initiates the request. Script alerts indicate how the request is progressing. Click the Stop button to cancel the request, or the Read button to view additional properties of the response, such as  and .

JavaScript
 
  

XDomainRequest

       

See also

转载地址:http://dttba.baihongyu.com/

你可能感兴趣的文章
我的友情链接
查看>>
c#关于数据库连接操作的案例
查看>>
聊聊最近接触的媒体查询!
查看>>
HAproxy指南之haproxy重定向应用(案例篇)
查看>>
学习 HTTP协议挺不错的一个类
查看>>
深入字节码 -- ASM 关键接口 MethodVisitor
查看>>
linux 文件权限
查看>>
Linux常用命令集合
查看>>
Oracle DML
查看>>
Linux - FHS文件系统层次标准
查看>>
报错:Invalid bound statement (not found)
查看>>
Linux GPT分区格式磁盘的相关操作
查看>>
通过Docker进程pid获取容器id
查看>>
L15.2 zabbix基础(2)组件说明介绍
查看>>
impdp 常见问题 10g/11g/12c 问题解决 ERIKXUE
查看>>
2013年1月工作小结 -- 上线后的懈怠
查看>>
敏捷宣言
查看>>
php Yii: 出现undefined offset 或者 undefined index解决方案
查看>>
Bash编程入门
查看>>
org.tinygroup.binarytree-二叉树
查看>>