Not able to Get the weather in the javascript weather mini project

Hi guys , so I’ve inserted my code and the output with it . I’m not able to get output for the code can someone pls help me . I’ve tried finding the error but could not find one . please can someone help me

Screenshot 2021-06-06 at 5.08.13 PM

here is the output screen . pls help guys

This is the updated code after some editing , please consider this and help me on this

Hi @kumarsamarth2021,

There is a typo error in your code. It is readyState but you have used readystate. The best method to debug your issue is - start using console.log in your code.

Do let me know in case you need any other information.

2 Likes

DOCTYPE html>

default text

Submit function show_temp(){ document.getElementById("output").style.color="red"; document.getElementById("output").style.fontsize="20px"; city=document.getElementById("city").value;
		httpRequest=new XMLHttpRequest();
		url="https://api.weatherbit.io/v2.0/current?&city="+city+" &key=4ed81e7b898a4b479eeedbb99833ef14";
		httpRequest.open("GET", url);
		httpRequest.send();

		httpRequest.onreadystatechange=function(){
			if(this.readystate==4&&this.status==200)
				{
					user_data=JSON.parse(this.responseText);
					document.getElementById("output").innerHTML=user_data.data[0].temp;
				}
		}
	}


</script>