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 ID: 54
Created On: Sun, Oct 18, 2020 at 9:13 PM
Last Updated On: Sun, Oct 18, 2020 at 9:13 PM
Authored by: Saeed Nobakht [[email protected]]

Online URL: https://www.navel.ir/article/what-is-the-equivalent-of-file_get_contents-$-url-in-javascript-or-typescript-54.html