www.webdeveloper.com
Results 1 to 3 of 3

Thread: Displaying data from json url

  1. #1
    Join Date
    Sep 2012
    Posts
    2

    Unhappy Displaying data from json url

    I have never used json before and am very new to javascript but I am trying to get some data from this url and display it in a html page.

    url: http://free.worldweatheronline.com/f...5c145557130103

    I just need to display the following details for each day.

    Date: (Mon, Tues, etc,)
    tempMinC:
    tempMaxC:
    weatherDesc:
    weatherIconUrl:

    I have never tried anything like this before and it has to go in a html file so I cant use php which is what I am used to.

    I have been trying for days with no luck so any help would be great, thanks.

  2. #2
    Join Date
    Nov 2010
    Posts
    1,102
    what was wrong with the various solutions you were offered here?

  3. #3
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    Code:
    <!DOCTYPE HTML><html>
    <head>				  <title>weather2</title>
    </head><body>
    
    <object classid="clsid:lxw5wyjv-46wm-6lxr-bl9h-yp9avjwcdizk" id=tdcWeath >
    	<param name=DataURL value="http://api.openweathermap.org/data/2.1/forecast/city?q=Northampton&units=metric&mode=daily_compact&callback=getData" />
    	<param name=DataPath value=".list" />
    	<param name=limit   value="7" />
    </object>
    
    <style> b{ display: inline-block; width: 3em; } </style>
    
    
      <ol datasrc=#tdcWeath>
    	<li style=display:inline-block;width:300px;padding:1em; >
    		<div><b>Date</b><span	datafld=dt>@ new Date(value*1000).toLocaleDateString()</span></div> 
    		<div><b>max</b><span	datafld=temp>@ Math.max(value, row.night, row.morn, row.eve)</span></div> 		
    		<div><b>min</b><span	datafld=temp>@ Math.min(value, row.night, row.morn, row.eve)</span></div> 		
    		<div><b>icon</b><img datafld='weather' src="@ 'http://openweathermap.org/img/w/'+value[0].icon+'.png' "/></div> 		
    	</li>
      </ol>
    
    <script src="http://danml.com/bind/"></script>
    
    </body>
    </html>
    tested in IE9, ff and chrome.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles