Iman Kayum Munajir Iman Kayum Munajir - 1 month ago 13
jQuery Question

how to loop data json/return one by one/split one by one

i have data json like this:

{"output":{"id":"1","nama":"one"}},
{"output":{"id":"2","nama":"two"}},
{"output":{"id":"3","nama":"three"}}


how to make the data json return one by one.

example result like this:

loop 1

{"output":{"id":"1","nama":"one"}}


loop 2

{"output":{"id":"2","nama":"two"}}


loop 3

{"output":{"id":"3","nama":"three"}}


thanks,hope someone can answer :D

Answer

Are you looking for each loop?

var data = [{"output":{"id":"1","nama":"one"}},
{"output":{"id":"2","nama":"two"}},
{"output":{"id":"3","nama":"three"}}];

$.each(data, function(i, item) {
    console.log(item);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>