Local weather app Help ajax error

Local weather app Help ajax error
0.0 0

#1

Sorry, if this question has been posted before. The ajax function is returning error function and not going to success.
Below is the code snippet.

function getWeather(lat1,lon1){

$.ajax( {
type: “GET”,
dataType: “json”,
url:“http://api.openweathermap.org/data/2.5/weather?lat=”+lat1 +"&lon="+lon1+"&appid=c5b4e74b23c2533b06b1cd304b46d3b9",
success: function(data){
console.log(“hey”);
},
error: function(){
console.log(lat1+" " + lon1);
}
});
};

Output:
“41.5139193 -81.6747295”

I have tried different things, used getJson, tried in firefox, the url has the JSON object, but the code isn’t going to success function.

Any help is appreciated.


#2

Load ur pen via http instead https
think that because this http://openweathermap.org/price
u can only get ur data via http


#3

Hi… thanks for the reply… when i load the pen via http the navigator.geolocation.getcurrentposition shows error. When i load via HTTPS it shows me the coordinates but the success callback in ajax doesn’t work. Can’t seem to know the problem. Two days went by without any progress.


#4

U can make two function as callbacks like
navigator.geolocation.getCurrentPosition(successCallback,errorCallback,

And if ur browser support this geolocation but can’t determine position then it will call errorCallback

in errorCallback u can fetch your position getting JSON from
http://ipinfo.io/json

*i’ll later check what can cause that error http - geolocation u mentioned


#5

Thanks again for the quick reply. That error is the one I have written for the error callback in navigator function. I didn’t think of getting coordinates even in error function. I will try the one you mentioned and will update.


#6

If i get the location from [http://ipinfo.io/json] in my error callback in navigator function, the ajax is working via HTTP. Thanks a lot for the suggesstion.


#7

This guy explain thing
https - for weather api
and
http - for geolocation

Also if u access via https this https://ipinfo.io/json u get msg:

SSL access is restricted to paid plans. See http://ipinfo.io/pricing for more details, or contact us via http://ipinfo.io/contact