Bolt Iot Training: JavaScript Basics - 2 :- Ajax in Javascript(code)

I am doing the training of Bolt IoT.
There is this slight issue for the AJAX code part please check out my code, I also have included what the console in Google is showing.
Please Reply ASAP.
Thank you.

Hi @ajitmec,

Replace the URL with in the code and try if this is working.

Here is the code for your reference

<!DOCTYPE html>
<title>User Data Fetcher</title>
<p id="output">Default text</p>
<input id="user_number">
<button onclick="update_user()">Submit</button>
<script type="text/javascript">
function update_user() {
    var user_number = document.getElementById("user_number").value;
    var httpRequest = new XMLHttpRequest();"GET", "" + user_number);
    httpRequest.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
            var user_data = JSON.parse(this.responseText);
            document.getElementById("output").innerHTML =;

Let us know if you are still facing the issue

1 Like

Thank you so much! @rohit.ts
It worked!