Reputation: 48711
I've a URL that its contents are also JavaScript codes, I want to get the contents of this URL via JavaScript something like to file_get_contents()
in PHP and show them to the user using the alert()
function.
Upvotes: 13
Views: 64126
Reputation: 1326
you can get the contents from that URL by using jQuery
$.get('website_url', function(data) {
alert(data);
});
Upvotes: 17
Reputation: 60747
You can use XMLHttpRequest in Javascript to fetch datas from an external URL. Here is a good resource : http://www.w3schools.com/ajax/default.asp (I usually don't recommend them, but the AJAX tutorial is really good).
Also, this had to be there :
Upvotes: 66