HTTP GET from remote domain
(Ajax requests only seem to work on the same domain)
(I want to pass one parameter and receive back the HTML)
Thanks in advance and kind regards
the remote site must set the access-control http headers in their html/data response.
otherwise, you can use YQL's html module to query 3rd party sites for free without needing custom server code.
Thanks for both of your replies!
Incredible, that such a simple wish is so complicated.
I found this on the net:
How do they do that?
What do you think of it?
Is it something similar to the YQL module, that rnd me was mentioning?
It's worth mentioning that I have all domains under my control.
So altering the access-control http headers on the server side would not be a problem.
(I'll be using PHP on the server-side)
Any other ideas?
Cheers and kind regards
Did you solve this and may I ask how? I am Having the same issue and wonder how to proceed.
You could make the request from the same domain server, process the get and return it. If using PHP on the back end, use http_get and perhaps something to parse the reply.
if you control the servers, just add the headers.
YQL is more-or-less a poor-man's simple php proxy. it's nice because it converts things to JSON, but the impossible part that is does is move bits from a restrictred domains into a JSONp url that can be added to any page using <script src=xxx /> tags.
Hi and thanks for your responses!
@rnd me: By saying "add the headers" you probably mean something like this? :
...by further researching this, I found out, all you have to do seems to be add the following code in PHP:
That's if you control the server, of course...
solved by adding:
header('Access-Control-Allow-Origin: *'); in PHP
prior to starting the echo(s).
(just tested it - you can even access the server via AJAX)
Thanks a million!
@teeb: Feel free to check out, what's necessary, if you don't control the server like in your case...
Best of luck!
@rnd me: Do you think I could use POST similarly this way, instead of GET?
yes, even delete and put could work, but it's customizable in the Access-Control-Request-Method header. if you POST anything other than urlformdata, you need that extra header in addition to your allow-origin one...
Originally Posted by arvgta
also make sure OPTIONS requests work on your server to enable pre-flights.
There is an Iframe (mypage1) within an Iframe (mypage2) of the origin site. I have access to the two pages with the i-frames only. I don't believe the origin site is jsonp compatible and cookies must be passed. Can headers be used on my 2 iframe pages to fill in form data with in the i-frame? What type of files need the headers in case I can get the origin site to help?
Thanks for your kind replies,
Thanks rnd me, very helpful! :-)
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)