vishnu
vishnu

Reputation: 879

how to retrieve page source of cross domain using javascript ajax

Hello i need to retrieve page source from site1.com to site2.com

I tried file_getcontents of php but my site is dynamic and unique for each users.

so i need to request page source using JAVASCRIPT

Upvotes: 2

Views: 124

Answers (2)

hvgotcodes
hvgotcodes

Reputation: 120198

like epascarello said, you can't due to the same origin policy. If you control both sites, you can use CORS to achieve it.

If you don't the best bet is to make requests to the domain you control, and have your server fetch what you need from the other url. It's called proxying. It's not that difficult to do.

Upvotes: 2

epascarello
epascarello

Reputation: 207511

You can not do it because of the same origin policy unless the page and browser supports CORS.

Upvotes: 2

Related Questions