I have the following script, which essentially extracts each value from the "data" array being passed and returns json value.
function parsejson(data) {
var temp2 = new Array();
if (data) {
$.each(data, function (i, val) {
vproductid = data[i].productid;
vproductname = data[i].product_name;
vexpirydt = data[i].expiry;
temp2.push({vproductid,vproductname,vexpirydt});
});
console.log([temp2]);
return [temp2];
}
}
So in this case "data" within my console log comes back as:
Array [ Object, Object ]
Which contains the following objects -> values, etc, and in some instances my "expiry" date value is blank space, but still appears to work properly in Firefox and Chrome.
The issues seems to be exclusively with IE 11 in my case.... I keep getting the following Error in IE only which ties back to the "push" to append to my array somehow. I don't know if it's a syntax error or the way in which I'm trying to append to my array, but obviously I'm doing something wrong. My intention is simply to return a second array in json format, so might be a simpler way.
SCRIPT1003: Expected ':'

datais an Array, you can do this more cleanly with.map()...var temp2 = data.map(function(o) { return {vproductid:o.productid, vproductname:o.product_name, vexpirydt:o.expiry} })