Message from JavaScript discussions

August 2017

— Tested :3

— 

Language:

js


Source:
var a = JSON.parse('[{"2017-07-28":[{"id":1,"produk_id":1,"nama_id":1,"jumlah_user_id":1,"harga":"50000","tanggal_efektif":"2017-07-28"}]}]');

for(x in a)
for(y in a[x])
for(z in a[x][y])
console.log(a[x][y][z]['id']);


Result:
1

— 🤔 not work

— And i need to make a variable of that? how to variable a json that called in ajax?

— 🤔 write one before, but doesn't work

— You shouldn't use for..in for arrays

— Wow 🌚

— 😅 what was wrong?

— AJAX always response with a string, you must use JSON.parse to get arrays

— Or $.getJSON

— Https://stackoverflow.com/a/22892729

— ammarfaizi2 TRGWII i feel like i doesn't get it at all