Forum Moderators: open

Message Too Old, No Replies

Alternative to Ajax XMLHttpRequest domain limitation?

ajax

         

jason1989

3:47 pm on Jan 27, 2009 (gmt 0)

10+ Year Member



I have an interactive Ajax application that loads within a <div></div> embedded into my static html pages. The application nicely expands as required automatically (unlike an iframe would).

A limitation is that the Ajax data must be located on the same domain due to XMLHttpRequest security that does not allow it to pull data from other domains.

Is there any other way to embed my application using javascript so that my application may be shared amongst various domains I own?

Thank you,

Jason

P.S. I would like for the solution to be client side javascript and not a server side solution. The reason is that I have some html & php sites that I'd like to embed the app into. The reason that I don't use an iframe is that the height for the app expands during use.

jason1989

7:59 pm on Jan 28, 2009 (gmt 0)

10+ Year Member



I suppose that this is an XMLHttpRequest limitation that I'll have to live with.

Other than an iframe, the only alternative would be embedding the html (from the other domain) on the server and not on the client because of the limitation.

eelixduppy

8:50 pm on Jan 28, 2009 (gmt 0)



>> html & php sites

PHP is a server-side technology. You would be able to do it with that.

Gibble

10:11 pm on Jan 28, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There are ways around it, in short, as long as you control the domains and code, you'll be able to to

Refer to the following:
[ejohn.org...]

Silverlight...
[msdn.microsoft.com...]

There's other techniques as well
[codeproject.com...]

jason1989

11:42 pm on Jan 28, 2009 (gmt 0)

10+ Year Member



eelixduppy, thanks for the response.

> html & php sites

>> PHP is a server-side technology. You would be
>> able to do it with that.

This was something I had considered before embedding my application with AJAX. What I was going to do was to write a C++ filter that intercepts the http request, scans for tags within the html of the desired page, i.e. {{my_app}} and then gets and insert the application's html within the tag.

Pro:

1) no ajax nor javascript required.
2) the entire page including the embedded application's data gets indexed by search engines.
3) can be used on html, php, or any other site.

Con:

1) no more web server buffering of html files since the file is read and dynamic data is inserted within each request.

I have an older, heavily used server and don't want to burden it further, so I chose the AJAX method even though it seems that the AJAX data does not get indexed by search engines.

jason1989

11:43 pm on Jan 28, 2009 (gmt 0)

10+ Year Member



Gibble,

Thanks for providing the links, very interesting, especially the one about ajax proxy.