I’m trying to fetch some simple text over HTTP from JavaScript:
$(function() {
$.get("http://mydomain.com/path", function(result) {
console.log(result);
});
});
The result should be text/html, but is basically only a simple key-value string, no HTML tags whatsoever. The page is in my control, but is supplied by a third-party (closed-source) so I can’t modify the Java that serves out this page.
How can I get the contents of this page from JavaScript?
You’ve simply gotta use
either PHP/ASPyour serverside language to retrieve the cross-domain request or use a service such as a cross domain ajax service created by Yahoo!.It uses JSONP which is allowed to do very strict cross-domain requests, but asking from Yahoo! they will retrieve any page on the internet.
http://james.padolsey.com/javascript/cross-domain-requests-with-jquery/