₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,065 members, 8,420,130 topics. Date: Thursday, 04 June 2026 at 11:52 AM

Toggle theme

Please I Need Help From A Good Javascript Programmer - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingPlease I Need Help From A Good Javascript Programmer (780 Views)

1 Reply

Please I Need Help From A Good Javascript Programmer by Weezyval(op): 11:31pm On Jun 29, 2015
please i need help...who can help me loop through this json object, i want to loop through the daily object using javascript but am having some difficulties.

my code
success: function(json) {
console.log(json);
$("#current_temp"wink.html(Math.round(json.currently.temperature)+"°F"wink;
$("#current_summary"wink.html(json.currently.summary);
$("#current_temp"wink.attr("data-icon",icons[json.currently.icon]+" "wink;
$("#timezone"wink.html(json.timezone);
var newDate = new Date();
newDate.setTime(json.currently.time*1000);
dateString = newDate.toUTCString();

document.getElementById("time"wink.innerHTML = newDate;
for ( var i = 0; i < daily.data.length; i++) {
var DOM = jQuery('#DOM');
var obj = data[i];
console.log(obj);
DOM.append("<li>"+obj.summary+"<li>"wink;
};

},
error: function(e) {
console.log(e.message);
}


I will be very gratefull if anyone can help me out. Thanks

the json object from the callback function

Object { latitude: 41.879003, longitude: -87.63675, timezone: "America/Chicago", offset: -5, currently: Object, minutely: Object, hourly: Object, daily: Object, alerts: Array[1], flags: Object }

the json Daily data structure(They are 8 in number) The second image is an expanded view of one of the daily object

Re: Please I Need Help From A Good Javascript Programmer by IamGodzilla: 1:36pm On Jun 30, 2015
I don't really understand how your code is, because of the way it's formatted.
But looking at the photo you attached.

to loop through an array [], you do this.
for (var i=0 i< daily.length; i++){
return daily[i]
}
And to loop through an object {}, you do this.
for(var key in object){
return object[key]
}
This is just an example of how you would loop. you probably are looping through an object using the array format.
Also where you have daily.data.length, try daily.data[i], however I would recommend you save it to a variable,
e.g var newVar = daily.data;
then you could do newVar.length
Re: Please I Need Help From A Good Javascript Programmer by Weezyval(op): 9:49am On Jul 02, 2015
IamGodzilla:
I don't really understand how your code is, because of the way it's formatted.
But looking at the photo you attached.



to loop through an array [], you do this.


And to loop through an object {}, you do this.


This is just an example of how you would loop. you probably are looping through an object using the array format.
Also where you have daily.data.length, try daily.data[i], however I would recommend you save it to a variable,
ok' thanks a lot I appreciate
1 Reply

Lets Start A Real Web-deveopment Course Here Html+css+javascript+php+mysqlWere Can I Download Free Video Tutorials On Javascript Or RubyMy Web Development Consultancy Thread(html, CSS, Javascript, Jquery, ASP.NET)234

Xpath InjectionUploading Software Created In Vb6 To A Website....