Problems with Local Weather App

I have some problems with my Js code. I don’t understand why it does not work but I assume the problem is in line 6?
Project is here: http://codepen.io/Andrew1024/pen/akLJjo

I think you forgot to add jquery to your project :slight_smile:

Even if I add JQuery, nothing happens. :pensive:

Hi Andrew,

You need APPID to use this API. Please register on weather site and get your APPID.

Then, analyse thoroughly what that API returns.
By data[5].content you’re trying to use array but API returns a complex JSON object.

For example,
data.weather[0] returns first element (which is JSON object) of value (which is an array) for id=“weather”.
data.wind.speed returns value of id=“speed” from JSON object stored against id=“wind”

Done. But it seems that data can not be gotten.

I have looked through the Chrome and there are "Failed to load response data’. I have already checked the keys and they are corrent.

Now I am stuck again :pensive:

Value in $(’#location’) is not as expected.

Below is a screenshot of debugging in Firebug

Fixed that stupid mistake. But all the same something is not working correctly. The server does not respond any data.

The problem right now is that no location is being passed into your API call. Your location, if you console.log it out (console.log($(’#location’).text())), is actually “Search.” You need to use a different way of getting the individual’s location. Since it looks like you’re wanting to have a form submit, try this:

http://api.jquery.com/val/

Use jQuery’s .val() in conjunction with a class or an ID attached to the text input to access this data.

EDIT: Note, do not use #location to grab that element’s value. Assign the element an ID.

Even if I change the .text() with the val() it seems something is not working properly. Again “Failed to load response data”

Add http:// before your link in getJSON() otherwise it calls the site at the same domain (codepen.io)

Then, to avoid refreshing the page on clicking the button, add event.preventDefault(); just after .click(function(event){ (found this idea here)

I changed completely everything but now I can’t get the request from OpenweatherAPI.

Openweathermap doesn’t support https for free accounts. Remove the s and it should work! Be sure to load your Codepen in http, not https.

Another problem happened. When I try to get the value of temperature I can not get it.