I've returned JSON data from controller (via ajax), and wanna access to this data. This is a list of objects (array): key - value, so I wanna use .each() to access all data. Array like that:
[{"filePath":"Desktop.zip","fileStatus":"Uploaded"},{"filePath":"Desktop\\dates.xml","fileStatus":"Uploaded"}]
and code is:
$.ajax({
url: '@Url.Action("GetFilesNames", "Home")',
type: 'POST',
success: function (data) {
$.each(data, function (value) {
console.log(value['filePath'], value['fileStatus']);
});
}
});
But data.each value is undefined.
So I've tried to console.log all data, json.stringify it, parse it (but somehow with error), and parse stringyfied version, but in makes no sense. Even If I use this stringified version (paths) or parsed stringified version (listOfFiles) with .each - same result: undefined.