Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Comet Javascript error

I'm using Orbited as a Comet server on localhost. It is listening to ports:

9000 for http
61613 for stomp

My JavaScript debugger is reporting error: JSON is not defined in the line:

var vals = JSON.parse(payload);

What could be the cause and how do I resolve this issue?

like image 519
Alex Avatar asked Sep 19 '26 21:09

Alex


1 Answers

The JSON library is not built into Javascript. You must include a javascript JSON library. If you use the one I linked, your code should work.

Alternatively, since JSON is a subset of Javascript object literals, you may be able to do this:

var vals = eval('(' + payload + ')');
like image 116
Kenan Banks Avatar answered Sep 22 '26 09:09

Kenan Banks



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!