Suhail Mumtaz Awan
Suhail Mumtaz Awan

Reputation: 3483

how to display multiple json result in html

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

Upvotes: 0

Views: 891

Answers (2)

Andrey
Andrey

Reputation: 1553

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

Upvotes: 1

Dean.DePue
Dean.DePue

Reputation: 1013

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.

Upvotes: 1

Related Questions