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
here is the output screen . pls help guys
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>