AJAX Client-side Get Code Of Another Site
Is it possible to create a client-side script to get code of another website, similar to PHP get_file_contents but from client-side not server side?
If so can you please tell me how or provide some code to use ajax to return the code of another website into a variable please.
Any help would be greatly appreciated.
It isn't possible. Client side (browser) security restrictions will not allow it.
As John said, it's intentionally blocked. (It's theoretically possible and there's no reason that it won't work except that browsers block it.)
There are two possible ways around this. However, in most cases this is a problem anyway, since you may not have permission from the external site. In some cases (if you own both, for example) it may be fine, so I will post the workarounds anyway.
1. I believe that there is some way to create a document that allows this in your server: crossdomain.xml. It may not work in all cases, and you might need the same file on both servers. The intent of that is to allow this sort of thing if you have permission. I don't know any more information about this and the one time I tried it I didn't get it to work-- then I find another approach and didn't need to do it any more. Try google or maybe someone here will know more than I do.
This should work in all cases. But still be careful and think about whether this is really the right approach to solving your problem.
Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum