I'm receiving JSON data from a remote server at openweathermap.org. Can anyone help me identify issues with my code? Here is an example of the server's response here
var getWeatherJSON = function (city) {
var httpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
var jsonText;
httpRequest.onreadystatechange = function () {
//====jsonText after getting respons equals null====
jsonText = httpRequest.readyState == 4 && httpRequest.status == 200 ? httpRequest.responseText : null;
}
httpRequest.open("GET", "http://api.openweathermap.org/data/2.5/weather?q=" + city, true);
httpRequest.send();
return jsonText;
}