0

I am working with weather api, having problem with displaying the multiple results ad using $.each function...

Can someone please tell if i am doing wrong,,,, Script&html

<div id="fj"></div>
    <script type="text/javascript">
        $(document).ready(function () {
            var teams;
            $.getJSON("http://api.openweathermap.org/data/2.5/forecast/daily?lat=33.5689&lon=72.6378&cnt=10", function (dataDD) {
                //do some thing with json  or assign global variable to incoming json.
                var tasks = $.parseJSON(dataDD.city);
                alert(tasks);
                //alert('empLoggedId');
                $.each(tasks, function (key, value) {
                    $("#fj").append(data.weather.description);

                });
            });
            });
    </script>

Any kind of help or reference will be appreciated...Thanks for your time

1
  • @PeterKA thanks for response, i am willing to load this multiple data into html which i got from api url Commented Jul 24, 2015 at 11:40

2 Answers 2

1

You should not parse already parsed as JSON data here $.parseJSON(dataDD.city);. And check the structure of the returned object.

Fixed example on codepen

Sign up to request clarification or add additional context in comments.

1 Comment

thanks for answer, i will surely accept after make it into work, +1 for effort
1

You could try to use some HTML:

 $.each(tasks, function (key, value) {
                $("#fj").append(<p>data.weather.description</p><br />);

            });

Plus, I'm not sure what "data" is here.

1 Comment

thanks for answer, i will surely accept after make it into work, +1 for effort

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.