extjs - Built a JSON from string pieces -
i work line chart in extjs4 now. chart based on data of store. store change data 'loadrawdata()' function. familiar situation, isn't it?
ajax sends strings every 10 seconds , need built json pieces of strings. i'm trying:
success: function(response) { var requestmassive = json.parse(response.responsetext); var jarray = []; for(var i=0;i<requestmassive.length;i++){ var firstpiece = json.parse(response.responsetext)[i].date; var secondpiece = json.parse(response.responsetext)[i].connectcount; var recording = "{'machinesplayed':"+firstpiece+", 'machinesonline':"+secondpiece+"}"; jarray.push(recording); } jarray = '['+jarray+']'; store.loadrawdata(jarray); }
but wrong way. how properly?
you use loaddata()
function instead of loadrawdata()
. loaddata()
needs array of objects.
success: function(response) { var requestmassive = json.parse(response.responsetext); var jarray = []; for(var i=0;i<requestmassive.length;i++){ jarray.push({ machinesplayed: requestmassive[i].date, machinesonline: requestmassive[i].connectcount}); } store.loaddata(jarray); }
Comments
Post a Comment