I am about to give up, and just convert my JSON to a string. But the ability to send JSON objects back and forth through AJAX seems like such a powerful tool, especially since I'm doing a lot of work with SQL databases.

I am using php v 5.2.16. I read there might be some compatibility issues with json_encode(), but only before php 5.2.....

I appreciate the help!

venegal

02-22-2011, 03:55 PM

I am about to give up, and just convert my JSON to a string.

I'm not sure what you mean by that. Your JSON string is a string.

Anyway, can you show this on a live site? There are so many things that could potentially fail, so it's hard to tell you anything without seeing it in action.

schw0722

02-22-2011, 05:12 PM

Sorry, what I meant was that I could turn the data object into a string separated by ",". For example:

Then in the php code, separate the dataString back into an array, and work with it like that. This doesn't allow me to send the same complexity of information to the php code, but it's the compromise I'm working with for now...

BTW, I'm having no trouble receiving JSON objects back from the php.

You can see a live version of the unsuccessful code here: here (http://dylmg.earthcreaturespottery.com/sandbox/AJAX/jsCaller.html)

venegal

02-22-2011, 06:46 PM

The problem is definitely in the PHP. The Javascript component sends and receives ok, but PHP isn't sending back the extended object, but a new one only containing "php_message".

Your PHP code looks ok though, so could you please do a var_dump on $_REQUEST (it would be better to use $_POST, btw), on $res (before and after adding the additional index), and on json_encode($res)? At one of those steps, something is failing.

schw0722

02-22-2011, 08:28 PM

I took a look at the php code, did a little more research, and I think I figured it out.
Apparently magic quotes are set on my server. The solution was just to add a stripslashes() tag.