How to use foreach parse the json type –
getData: function(id, dataid)
{
$.post('Action/Load.php',{
id: id
}, function(data) {
$(dataid).html(data);
});
}
data = {"file":"1","text":"Hello world","name":"Jenan","id":"1","url":"url"}
I would get text –
1 - Hello World - Jenan - 1 - url.
The
$.each()function only works on Arrays and jQuery objects.Here,
datais not an array, its a regular object.So, get the data from your Json this way :
EDIT:
If you have some of these objects in an Array like the one that follows :
Do like that :