Tuesday 15 April 2014

javascript - JSON.parse Unexpected character -


I have a zenzone object that is stored in a mangodiibi archive. Position of object 5x, 5i image, and Tecto board represents the position of the image.

At one interval, I send a request for a PHP file that responds with this object, and then I want to parse that object and move the fragments accordingly.

This is my request:

  $ GetJSON ("e4.php", "", function (data) {world = JSON .pars (data); Hill objects (world);});   

But I get: JSON. Pars: unexpected character

When I give console.log data firebug then gives me the right object, so I know that It's returning properly.

In e4.php:

  $ criteria = array ("name" => "world"); $ Doc = $ Collection-> Search one ($ criteria); $ Conn- & gt; near (); Print $ doc ['world'];   

Where conn is the connection, and the collection is archive I am working inside.

The database has been updated to e3.php:

 $ encoded veril = $ _REQUEST ['data']; $ Criterion = array ("name" => = "world"); $ Doc = $ Collection-> Search one ($ criteria); $ Doc ['world'] = $ encoded world; $ COLLECTION- & gt; Save ($ dock); $ Conn- & gt; near (); Print $ encoded word;   

Any ideas? I'm stumped

Thanks in advance.

Dasarize JSON for you, so the data object graph Will not be the string, not the string From documentation:

Success Returns the data returned to the callback, which is usually a JavaScript object or array that is defined by the JSON structure and $ ParseJSON () method.

So since data has already been deserialized, you do not want it or JSON.parse on it Calling is required. Doing so will call toString on data , which is either [object object] or [object size] >, Therefore JSON.parse is not being liked as input :-) Use directly data :

  $ GetJSON ("e4.php", "", Function (World) // & lt; === Name of the changed argument {moveObjects (world); // & lt; === used it directly}};   

Separately: As long as you did not show the world , your code was also hunting prey you might have written there Var but with the above changes, you do not need a variable, so ...

No comments:

Post a Comment