Reputation: 771
I'm trying to access and display the data stored in a particular url. But my code wasn't running correctly. Any suggestion for this?
function getData( theURL ) {
var xmlHttp = null;
xmlHttp = new XMLHttpRequest();
xmlHttp.open( "GET", theURL, false );
xmlHttp.send( null );
return xmlHttp.responseText;
}
var url = "https://cloudant.com/futon/document.html?acharya%2Ftoxtweet/ff558f75077e8c758523cd3bd8ffdf88";
getData(url);
Upvotes: 0
Views: 83
Reputation: 6190
Since XMLHttpRequest doesn't allow cross domain requests, I believe you can use three solutions. The usability will be depend on the services you are integrating.
Upvotes: 1
Reputation: 45
Another and pure-js solution is to utilize YQL, checked: http://christianheilmann.com/2010/01/10/loading-external-content-with-ajax-using-jquery-and-yql/ (scroll to the bottom for complete script) - works fine.
Upvotes: 0
Reputation: 324610
XMLHttpRequest only works on the same domain.
If you have a server-side setup, you could proxy the desired page so it arrives from your server.
Upvotes: 3