Advertisement
728x90
Browsers provide an XMLHttpRequest object which can be used to make synchronous HTTP requests from JavaScript.
javascript
1function httpGet(theUrl) {
2 var xmlHttpReq = new XMLHttpRequest();
3 xmlHttpReq.open("GET", theUrl, false); // false for synchronous request
4 xmlHttpReq.send(null);
5 return xmlHttpReq.responseText;
6 }Advertisement
Responsive Ad
🎯 Practice NowRelated Challenge
JavaScript Coding Exercise 85
Test your knowledge with this interactive coding challenge.
Start CodingAdvertisement
728x90
170of476