Ajax request javascript.html example not working

The ajax request, javascript.html example is not working, the code displays the page on the chrome with “default text” and “submit button”. When I enter a number(for ex 1) it does not update “default text” by the first_name from the web site. Please let me know how to fix this issue

Please send your code

@kushag09 below is the code

default text

submit function update_user(){ user_number=document.getElementById("user_number").value; httpRequest = new XMLHttpRequest(); httpRequest.open("GET","https://reqres.in/api/users/"+user_number); httpRequest.send(); httpRequest.onreadystatechange= function(){
		if(this.readystate== 4 && this.status== 200)
			user_data = JSON.parse(this.responseText);


Send HTML code as well

@kushag09, i got it. The mistake was the a typo in the if statement, the “s’” in readyState is caps i had written small s. Anyways thanks for your concern

1 Like