Forum Moderators: open

Message Too Old, No Replies

Reading pages in other servers

         

honkam

12:12 pm on Jun 26, 2008 (gmt 0)

10+ Year Member



Hi there,
just wanna to get my problem solved.

I am working with a web application, based on Java Script and AJAX.

Just like other applications, I would like to have a page,stored in
my sever, after successfully loaded in the client browsers, connects to
other servers, for example Google API, to include the response text in the loaded page.I have tried using XMLHttpRequest and innerHTML method, but restricted by the holy "same origin policy".

The special requirement of my project is I have to have the users of
my application connect to other servers strictly with their IPs due to
security reason.

Is there any AJAX proxy method that can solved my problem?
Is there any method the break the same origin policy? I just need to
obtain the reponseText and need not to alter the pages in other server.

Thank

httpwebwitch

4:32 pm on Jun 28, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



you'll need a proxy running on your own domain. This is typically a single script that accepts a URL as its parameter; the server-side script requests that URL and outputs the response. Since it's a script on your own domain, it solves the same origin problem. It can be built in PHP, ASP, JSP, ColdFusion or whatever you're running, normally only a few lines of code.

the URL your AJAX requests will look something like this:

[mydomain.com...]

Public APIs like Google Maps don't need that step. Instead, you hotlink some of their code directly onto your page with a <script> tag, and simply use the methods and properties provided by them. The <script> method doesn't heed any same origin policy, whereas XMLHttpRequest does.

honkam

5:54 pm on Jun 29, 2008 (gmt 0)

10+ Year Member



Thank for your help, httpwebwitch.

By using a proxy running in my domain and output the response by curl method, it will be that it is my server connects to the third party web site.
The security requirement of my project is it is the clients of my application who are connecting the third party web site directly.

can you figure out a solution?