|
jquery json problem - win vs unix?
I finally broke down and started using json for ajaxing data between client and server code (javascript/php in my case).
I am using JQuery. From the client side, the code uses the JQuery JSON plugin and goes something like...
function ClientRequest() {
var data = new Object();
data.command = "get_records";
data.data_records = "";
var dataString = $.toJSON(data);
$.post('mediabox.php', {data: dataString}, done_func);
}
function done_func(res){
var obj = $.evalJSON(res);
...
}
On the server side, the PHP code looks something like...
<?php
$res = json_decode($_REQUEST['data']);
...
...
echo json_encode($res);
?>
This all works fine on my Windows machine, however, when I upload the code to my provider (UNIX server), the code no longer works properly. The value of $res that is fed to done_func(res) is null.
I believe the problem has something to do with quotes. The $.toJSON() function returns something like "{"one":"1","two":"2"}". I've tried changing the double quotes to singles, but that didn't work. When I hard code some values without using the double quotes, it works fine on both servers, but when the double quotes are added, the value of "res" turns to null (on the Unix server only).
What am I missing?
|