I'm messing around object key value stuffs and hit a wall:
If I define an object's key:value pairs in the script and then get the value of a certain key, it works fine.
If I $.get an external txt file then it returns "undefined" for the value. If I iterate through the same imported file using $.each, it'll faithfully list each key:value pair.
Code:
$(document).ready(function() {
// DATE
var now = new Date(Date.now());
var mond = function() {
return ('0' + (now.getMonth() + 1)).slice(-2);
}
var dayd = function() {
return ('0' + now.getDate()).slice(-2);
}
var dayKey = mond() + dayd();
$.get('alldatestest.txt', function(data) {
var picsObj = {data};
alert(picsObj.dayKey);
/*$.each(picsObj, function(key,value) {
//alert(key + ':' + value);
if ( key = dayKey ) {
//alert('yes');
alert(value);
}
});*/
});
});
Here's the external file as reference above:
Code:
0810: '',
0811: '100315/5065359-R1-19-20_scaled.jpg',
1004: '100315/5065359-R1-19-20_scaled.jpg',
1008: 'images/CNV00016-interim.jpg'
A simple trick makes it terrifyingly easy to see whether or not someone has muted you on Twitter |