From server I receive JSON
object which is in this format:
[ { "Id": 1, "defNo": "ME-2-17", "ReportDate": "2013-10-04T00:00:00", "Remarks": "" } ]
to use it in the loop I am trying to convert it in an array through $.parseJSON(responseText
but after converting I am still unable to use it as console says that:
Uncaught TypeError: Object #<Object> has no method 'join'
Complete Function:
function exportToCsv() {
var formInfo = $("#requestSortForm").serialize();
$.post('../../REQUEST/GetSortedRequest', formInfo, function (responseText) {
data = $.parseJSON(responseText);
console.log($.parse(responseText));
var csvContent = "data:text/csv;charset=utf-8,";
data.forEach(function (infoArray, index) {
dataString = infoArray.join(",");
csvContent += index < infoArray.length ? dataString + "\n" : dataString;
});
var encodedUri = encodeURI(csvContent);
window.open(encodedUri);
});
}
I am following this example from an answer over SO
from Here