Read state 4 indicates that you got an response which is 404 (not found) in your case. It tells you that the server at
api.openweathermap.org is working (the 404 answer is from there) but that the local part of the URL is invalid.
Did you had a look at the 404 message in
xmlhttp.responseText
?
It should give you a hint about which part is invalid.
According to
Current weather data- OpenWeatherMap[
^] the default format is Jason and
callback
defines a JavaScript call back function which must be implemented. So there should be no need to use the
callback
or
mode
parameter.
You may also try it with just the
lat
and
lon
parameters, and - because it works in the browser - by using the URL entered in the browser for testing (that is setting your
url
variable to that fixed string).
Try also using a lower case
appid
parameter (parameters may be case sensitive).
See also this support thread (especially the post from Ivan Sep 15, 2015 03:51PM UTC):
OpenWeatherMap | Error: Not found city[
^]