Home » Categories » TypeScript

What is the equivalent of file_get_contents ($ url) in JavaScript or TypeScript?

Use Ajax

$.ajax({
    type: "GET",
    url: "http://www.flalottery.com/exptkt/ff.html"
}).done(function(data){
    console.log(data);
});

Or use a simple get request

$.get("http://www.flalottery.com/exptkt/ff.html", function(data) { 
    console.log(data);
});

Or use XHR

var xhr = new XMLHttpRequest();
xhr.open("GET", "http://www.flalottery.com/exptkt/ff.html", true);
xhr.onload = function () {
    console.log(xhr.responseText);
};
xhr.send();


Ref:
https://stackoverflow.com/questions/47003989/what-is-the-equivalent-of-file-get-contents-url-in-javascript-or-typescript
Article Rating (No Votes)
Rate this article
  • Icon PDFExport to PDF
  • Icon MS-WordExport to MS Word
 
Attachments Attachments
There are no attachments for this article.
Comments Comments
There are no comments for this article. Be the first to post a comment.
Related Articles RSS Feed
There are no related articles for this article.