$(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); } });*/ }); });
0810: '', 0811: '100315/5065359-R1-19-20_scaled.jpg', 1004: '100315/5065359-R1-19-20_scaled.jpg', 1008: 'images/CNV00016-interim.jpg'
$.get('alldatestest.txt', function(data) { var picsObj = JSON.parse(data); alert(dayKey + ' ' + picsObj[dayKey]); });- returns "0812 100315/5065359-R1-19-20_scaled.jpg"
{"0810":"images/CNV00016-interim.jpg", "0812": "100315/5065359-R1-19-20_scaled.jpg", "1004": "100315/5065359-R1-19-20_scaled.jpg", "1008": "images/CNV00016-interim.jpg"}
Object.keys(obj).indexOf(key)
(you're not supposed to be able to do indexy stuffs on objects, but there you have it (angel) )
http://www.designartcraft.com/photo/afbp.htm
*subject to buggery (NJ), breakage and general fail