Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-05-2009, 03:43 AM   PM User | #1
snoodle
Regular Coder

 
Join Date: May 2007
Location: Manteca, CA
Posts: 219
Thanks: 4
Thanked 0 Times in 0 Posts
snoodle is an unknown quantity at this point
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?
snoodle is offline   Reply With Quote
Old 03-05-2009, 06:31 AM   PM User | #2
snoodle
Regular Coder

 
Join Date: May 2007
Location: Manteca, CA
Posts: 219
Thanks: 4
Thanked 0 Times in 0 Posts
snoodle is an unknown quantity at this point
Oooooooh. That was a fun few hours... The "magic_quotes" flags on my provider's server were set to On while my local "php.ini" had them set to false.
snoodle is offline   Reply With Quote
Old 03-05-2009, 10:35 AM   PM User | #3
Kor
Red Devil Mod


 
Kor's Avatar
 
Join Date: Apr 2003
Location: Bucharest, ROMANIA
Posts: 8,478
Thanks: 58
Thanked 379 Times in 375 Posts
Kor has a spectacular aura aboutKor has a spectacular aura about
You should have known that javascript and JSON have nothing to do with the Operating System. The only thing that matters for the client-side languages is the browser. Nor javascript/php would will be influenced by the Operating System: it is just a dialogue between the user (via his browser) and the server. Now, if the server is instructed to recognize php, it will do it, nomatter it is an Unix or a Windows system based server.
__________________
KOR
Offshore programming
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

Last edited by Kor; 03-05-2009 at 10:39 AM..
Kor is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:48 AM.


Advertisement
Log in to turn off these ads.