javascript - Parse response using Jquery -
i have parse response server, response like..
[4,"1.0",1368544417760] [1,"great west road","222",1368544595000] [1,"ruislip manor station","114",1368544479000] [1,"bank station / threadneedle street","26",1368544731000] [1,"belvue school","e10",1368545955000] [1,"brunel road","283",1368544706000] [1,"annesley avenue","303",1368545930000] [1,"brixton station road","35",1368545854000] [1,"southampton row","91",1368545537000] [1,"camden road station","29",1368545008000] [1,"fulham cemetery","74",1368545210000]
the response doesn't seem json or xml. please me know how parse such type of response using jquery. have update dom based on response , response getting updated @ regular interval automatically.
the first number may indicator of sort of data in rest of "array".
i'd
parse each line if json. it'll turn javascript array.
var array = json.parse(oneline); // many browsers support this.
then pull bits out , put them proper object name. (how depends on 1st element, perhaps.)
var obj = {}; if (array[0] == 1) { obj.station = obj[1]; obj.number = obj[2]; obj.timestamp = obj[3]; // guessing is, too. }
do whatever need data object.
put in loop. repeat until done.
Comments
Post a Comment