Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    May 2007
    Location
    Manteca, CA
    Posts
    219
    Thanks
    4
    Thanked 0 Times in 0 Posts

    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?

  • #2
    Regular Coder
    Join Date
    May 2007
    Location
    Manteca, CA
    Posts
    219
    Thanks
    4
    Thanked 0 Times in 0 Posts
    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.

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    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.
    Last edited by Kor; 03-05-2009 at 10:39 AM.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •