3

I am building a SP hosted app in Office 365. The app is to get current weather, I am using api but it returns nothing. I have tried with the same code in ASP.Net Web Application and it worked. Why is it not working in SP hosted app? As I said it return nothing. Thx!

my code:

$(document).ready(function () {
            $.get("http://api.openweathermap.org/data/2.5/weather?q=Stockholm&APPID=23aabf5e2289b606d18f670397dcf3cb&units=imperial", function (response) {
                console.log(response);
                $("#name").text(response.name);
                $("#temp").text(response.main.temp);
                $("#humidity").text(response.main.humidity);
            }); 
        });


<div id="name"></div>
        <br /> 
        <div id="temp"></div>
         <br /> 
        <div id="humidity"></div>
3

Most likely this is because you are making an http request on an https site, this is a security issue and browsers will block it. Check to see if they offer the api over https and use that instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.