root / trunk / web / dojo / dojox / io / proxy / README @ 10
History | View | Annotate | Download (4.01 KB)
| 1 |
------------------------------------------------------------------------------- |
|---|---|
| 2 |
Project Name |
| 3 |
------------------------------------------------------------------------------- |
| 4 |
Version 0.6 |
| 5 |
Release date: 01/31/2008 |
| 6 |
------------------------------------------------------------------------------- |
| 7 |
Project state: |
| 8 |
experimental |
| 9 |
------------------------------------------------------------------------------- |
| 10 |
Credits |
| 11 |
James Burke (jburke@dojotoolkit.org) |
| 12 |
------------------------------------------------------------------------------- |
| 13 |
Project description |
| 14 |
|
| 15 |
The XHR IFrame Proxy (xip) allows you to do cross-domain XMLHttpRequests (XHRs). |
| 16 |
It works by using two iframes, one your domain (xip_client.html), one on the |
| 17 |
other domain (xip_server.html). They use fragment IDs in the iframe URLs to pass |
| 18 |
messages to each other. The xip.js file defines dojox.io.proxy.xip. This module |
| 19 |
intercepts XHR calls made by the Dojo XHR methods (dojo.xhr* methods). The module |
| 20 |
returns a facade object that acts like an XHR object. Once send is called on the |
| 21 |
facade, the facade's data is serialized, given to xip_client.html. xip_client.html |
| 22 |
then passes the serialized data to xip_server.html by changing xip_server.html's |
| 23 |
URL fragment ID (the #xxxx part of an URL). xip_server.html deserializes the |
| 24 |
message fragments, and does an XHR call, gets the response, and serializes the |
| 25 |
data. The serialized data is then passed back to xip_client.html by changing |
| 26 |
xip_client.html's fragment ID. Then the response is deserialized and used as |
| 27 |
the response inside the facade XHR object that was created by dojox.io.proxy.xip. |
| 28 |
------------------------------------------------------------------------------- |
| 29 |
Dependencies: |
| 30 |
|
| 31 |
xip.js: Dojo Core, dojox.data.dom |
| 32 |
xip_client.html: none |
| 33 |
xip_server.html: none (but see Additional Notes section) |
| 34 |
------------------------------------------------------------------------------- |
| 35 |
Documentation |
| 36 |
|
| 37 |
There is some documentation that applies to the Dojo 0.4.x version of these files: |
| 38 |
http://dojotoolkit.org/book/dojo-book-0-4/part-5-connecting-pieces/i-o/cross-domain-xmlhttprequest-using-iframe-proxy |
| 39 |
|
| 40 |
The general theory still applies to this code, but the specifics are different |
| 41 |
for the Dojo 0.9+ codebase. Doc updates hopefully after the basic code is ported. |
| 42 |
|
| 43 |
The current implementation destroys the iframes used for a request after the request |
| 44 |
completes. This seems to cause a memory leak, particularly in IE. So, it is not |
| 45 |
suited for doing polling cross-domain requests. |
| 46 |
------------------------------------------------------------------------------- |
| 47 |
Installation instructions |
| 48 |
|
| 49 |
Grab the following from the Dojox SVN Repository: |
| 50 |
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/io/proxy/xip.js |
| 51 |
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/io/proxy/xip_client.html |
| 52 |
|
| 53 |
Install into the following directory structure: |
| 54 |
/dojox/io/proxy/ |
| 55 |
|
| 56 |
...which should be at the same level as your Dojo checkout. |
| 57 |
|
| 58 |
Grab the following from the Dojox SVN Repository: |
| 59 |
http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/io/proxy/xip_server.html |
| 60 |
|
| 61 |
and install it on the domain that you want to allow receiving cross-domain |
| 62 |
requests. Be sure to read the documentation, the Additional Notes below, and |
| 63 |
the in-file comments. |
| 64 |
------------------------------------------------------------------------------- |
| 65 |
Additional Notes |
| 66 |
|
| 67 |
xip_client.html and xip_server.html do not work right away. You need to uncomment |
| 68 |
out the script tags in the files. Additionally, xip_server.html requires a JS file, |
| 69 |
isAllowed.js, to be defined. See the notes in xip_server.html for more informaiton. |
| 70 |
|
| 71 |
XDOMAIN BUILD INSTRUCTIONS: |
| 72 |
The dojox.io.proxy module requires some setup to use with an xdomain build. |
| 73 |
The xip_client.html file has to be served from the same domain as your web page. |
| 74 |
It cannot be served from the domain that has the xdomain build. Download xip_client.html |
| 75 |
and install it on your server. Then set djConfig.xipClientUrl to the local path |
| 76 |
of xip_client.html (just use a path, not a whole URL, since it will be on the same |
| 77 |
domain as the page). The path to the file should be the path relative to the web |
| 78 |
page that is using dojox.io.proxy. |
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|