Reputation: 1503
Is it possible to get source code of any webpage with javascript at client side? With AJAX maybe?
But I need that the server I am downloading the url from does see the IP of the client.. with AJAX it will show my script server IP, right?
Thank you in advance.
Upvotes: 1
Views: 1875
Reputation: 5080
It should be possible to do so if you implement a service on your server that does the retrieval. So your AJAX-request would call a URL like the following:
http://myownserver.com/getContent?url=theotherserver.com
That way you could get around the XSS-security protection of your browser, but the remote server will then see the IP of your own server instead of that of the client.
Upvotes: 2
Reputation: 20131
Firstly, this is known as cross-site scripting (XSS) and is considered a security risk, so current browsers do not allow it.
More generally, if your page included a reference (an image, perhaps) sourced from server X, then server X would see the client's apparent IP, which could be a proxy server in their ISP, or their real IP.
Upvotes: 0
Reputation: 69981
Javascript can not fetch items outside of its domain.
An AJAX query is just a normal request done asynchronously. Everything that happens in a real request will happen in an AJAX request.
Regarding the IP thing, the request is coming from the client. Since Javascript is client based, so you will see the client's IP in the request.
Upvotes: 3