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
Posted by: Saeed Nobakht - Sun, Oct 18, 2020 at 9:13 PM. This article has been viewed 3219 times.
Online URL: https://www.navel.ir/article/what-is-the-equivalent-of-file_get_contents-$-url-in-javascript-or-typescript-54.html

Powered by PHPKB Knowledge Base Software