javascript - Getting the value of a js object key -
i need able value of object key. when console.log(event);
returned object, getting:
messageevent { ports: array[0], data: "{ "event":"playprogress", "data":{ "seconds":0.419, "percent":0.002, "duration":177.813 } }" }
i can't seem value of data.percent console.log(event.data.percent)
. doing wrong?
it looks event.data
string, , not nested object. "reasonably modern" browser, can:
var data = json.parse(event.data); console.log(data.percent);
more discussion on json.parse
can seen @ previous stackoverflow answer.
Comments
Post a Comment