Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] My first JSON object



TLUG,

Thanks so far for all the help.

Something isn't working, and I'm stuck. For a test, I'm just trying to send a JSON object to a PHP script that is going to just turn right around and send the data back.

Here's my Javascript:

var myJSON = { "name": "my_simple_object" };
$.post('jsonhandler.php', myJSON, showResult, "text");
function showResult(json_data_received)
{
console.log("The value of the JSON object is: " + JSON.parse(json_data_received));
}

And here's my PHP:

$data = json_decode(stripslashes($_POST['karamohJSON']));
Header("Content-Type: application/json");
echo json_encode($data);

Unfortunately, in the Firebug console I'm testing with, the value of the JSON object is always "null".

Where did I go wrong?

Thanks for any advice.

--
Dave M G


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links