tags:

views:

121

answers:

1

I am passing a json encoded string from javascript to a php file on the server via ajax. on my online server this works fine. but locally, it does not.

There are a few differences in the php installs in the 2 places. minor ones. both are php4. the install locally is actually a newer php4.

I'm trying to track down why this is happening. It looks like the json parsing on the server side with the pear servies_json (json.php), isn't parsing correctly. It manages the first brackets, but then it stops there, and all the internal data is lost?

Is there a php plug in or something that I need to install that keeps this from happening. A setting switch? Thanks for any help.

+1  A: 

json_decode() should be used on the server-side to decode the JSON object, it should work fairly consistently. Its sister function json_encode() is equally good for encoding an array/object to a JSON string which can be echoed in your javascript.

Both functions require php 5, for php 4 you can check out this code.

Click Upvote