Tuesday 15 January 2013

javascript - Parse Json data in Jquery -



javascript - Parse Json data in Jquery -

i new jquery, ajax , json. facing issue parsing of json data. have been through many questions on stackoverflow

jquery: parsing json objects html table

access / process (nested) objects, arrays or json

parse json in javascript?

how parse through json object in jquery?

and many more...

still not able parse json data.

my jquery looks :

$.ajax({ /* type : "post", */ url : "launchapptest", /* contenttype: "application/json; charset=utf-8", */ info : "processdateinput="+processdate, datatype : "json", async: true, success : function(result) { var od = json.stringify(result) ; var obj = json.parse(od); console.log(obj.od); console.log(obj.od.percentagecompleted); console.log(od); $.each(json.parse(od), function(idx, obj) { console.log(obj.tagname); }); } });

i have tried combinations parse data, js console print "undefined"

i able print json object :

{ "od": [ { "dateprocessed": [ "09/11/2014", "10/11/2014", "11/11/2014", "12/11/2014" ], "percentagecompleted": 25, "processrunning": 0, "remainingtime": 0, "successbatchcount": 0, "totalbatchcount": 0 } ], "processdateinput": "12/11/2014" }

please help me how can fetch dateprocessed array , percentage complete.

try code. $.ajax({ /* type : "post", */ url: "launchapptest", /* contenttype: "application/json; charset=utf-8", */ data: "processdateinput=" + processdate, datatype: "json", async: true, success: function (result) { var od = json.stringify(result); var obj = json.parse(od); $.each(obj, function (index, value) { console.log(obj[index][0].percentagecompleted); console.log(obj[index][0].processrunning); console.log(obj[index][0].remainingtime); console.log(obj[index][0].successbatchcount); console.log(obj[index][0].totalbatchcount); console.log(obj.processdateinput); $.each(obj[index][0].dateprocessed, function (ind, val) { console.log(val); }) }); } });

javascript jquery ajax json parsing

No comments:

Post a Comment