javascript - Adding string to an array filled with arrays -
i have array object contains arrays.
var webapps = [ ['leave empty'] ]; i'm ajaxing in content , end ajax resulting string this:
ajaxresult = ',["alex","somewhere, ny, 11334"],["zak","cherryville, fl, 33921"]'; my question is, how take returned string , add webapps array? all!
damien
as @bergi pointed out, idea make ajax call return valid json. if thats not have control over, need turn valid json, parse it, , concat webapps array:
var webapps = [ ['leave empty'] ]; var ajaxresult = ',["alex","somewhere, ny, 11334"],["zak","cherryville, fl, 33921"]'; //strip comma ajaxresult = ajaxresult.substring(1); //surround [] ajaxresult = "[" + ajaxresult + "]"; //parse ajaxresult = json.parse(ajaxresult); //and concat webapps = webapps.concat(ajaxresult);
Comments
Post a Comment