Back to Main Page
AJAX - Requesting a JSON file
AJAX stands for Asynchronous JavaScript And XML. It's used to request data from a server and recieve that data and send data to a server without reloading the page. It uses the XMLHttpRequest object to get or send HTTP responses within a page.
First we create an instance, then define a callback function to an event listener "onreadystatechange." When something changes after making a connection to the server with the xhttp.open method, the data is returned in JSON format.
In this example, I use 'GET' to make a call to an URL (www.api.bitcointrade.com) and the content is returned as a JSON string.
The Result:
See the result of the above code here at CodePen
See it in person at https://api.bitcointrade.com.br/v2/public/BRLBTC/ticker
Back to Main Page