开发者

how really Cross Document Messaging in HTML5 overcome same-origin policy that apply to XMLHttpRequest?

I am new, I am developing an application that uses distributed resource.

I have one server called "presentation server" which serves everything related to template and ajax application (css, images, js, ...)

The second server only for serving raw data (let say, when you send a "GET /resources/a-resource", it return "text/plain, 'abc' "), actually I am developing an embedded RESTful interface on a device.

I have a client that connects to the first server, downloads the template. Then, the ajax code retrieves raw data from second server and present to user using the template.

I have a cross-domain problem with ajax here I know. I also know some current solution such as jquery or script tag.

What I am really concerning here is the Cross Document Messaging capability of HTML5. But what I found is just, they open two windows (a window + an Iframe or a window + a window) and passing message between each other.

it is not really like one sending a "GET" to some other and process the returned data开发者_JAVA技巧, like XMLHttpRequest did.

Please show me how really Cross-document-messaging in HTML5 can over come my problem.

** In short, My pain here is the XMLHttpRequest did truely send a GET to other source but the Cross-document-messaging does not(as I know), I wander if HTML5 with Cross-document-messaging is able to do as XMLHttpRequest in sending a GET to other domain or not

I really thank you for that.


But what I found is just, they open two windows (a window + an Iframe or a window + a window) and passing message between each other.

That's not true. You can have multiple iframe's in a document, each coming from a different domain, and all of them can post and receive messages from each other. So you don't need to have the pages in completely separate windows.

Also since you control both the presentation and API server, you can just set the Access-Control-Allow-Origin header on the API server to only accepts clients coming from your presentation server. That will allow you to use AJAX as you normally would.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜