Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: [tlug] My first JSON object [SOLVED]
- Date: Tue, 13 Jul 2010 10:41:59 +0900
- From: Dave M G <dave@example.com>
- Subject: Re: [tlug] My first JSON object [SOLVED]
- References: <4C1C3348.90506@example.com> <20100619044940.GA18726@example.com> <4C23481B.1090904@example.com> <20100625080744.62b6b298.gstewart@example.com> <32853.61.193.161.149.1277458953.squirrel@example.com> <4C25510C.3090002@example.com> <20100626083312.3f29d97d.gstewart@example.com> <4C26F2F4.80600@example.com> <20100627173336.e2533f06.gstewart@example.com> <4C300FEB.30405@example.com> <4C308DC9.4040309@example.com> <20100704151513.4c0ce0b6.gstewart@example.com> <4C3B14A9.6050707@example.com> <4C3B2E5C.9090005@example.com>
- User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.10) Gecko/20100527 Thunderbird/3.0.5
TLUG,Okay, got it. It seemed that my sticking point was that when sending the JSON, I have to "stringify" it first.I thought that since I was basically hand writing out my JSON in JSON syntax it was already in string form. As it turns out, though, it's gotta be stringified anyway.Also, stripslashes() is necessary on the PHP side. Though I guess that depends on a server's magic quotes settings and whatnot. Works for me, anyway.So, to get the JSON data to go to the server and then back again, here's how the code had to be written:Javascript: var myData = { "name": "my_simple_object" }; var myString = JSON.stringify(myData) $.post('jsonhandler.php', {myJSON: myString}, showResult, "json"); PHP: $myArray = json_decode(stripslashes($_POST['myJSON']), true); Header("Content-Type: application/json"); echo json_encode($myArray);I'm calling this thread solved because even though I'm now going to embark on actually, y'know, doin' stuff with the data I'm sending back and forth, which I'm sure will give me more headaches, the fundamental process of moving data back and forth seems to be working now.Thanks to TLUG and all its members for the great support, both on list and off!-- Dave M G
- Follow-Ups:
- Re: [tlug] My first JSON object [SOLVED]
- From: Darren Cook
- References:
- Re: [tlug] My first JSON object
- From: Dave M G
- Re: [tlug] My first JSON object
- From: Fredric Fredricson
- Re: [tlug] My first JSON object
- From: Godwin Stewart
- Re: [tlug] My first JSON object
- From: Dave M G
- Re: [tlug] My first JSON object
- From: Dave M G
Home | Main Index | Thread Index
- Prev by Date: [tlug] Japanese fonts look insane in Java
- Next by Date: Re: [tlug] My first JSON object [SOLVED]
- Previous by thread: Re: [tlug] My first JSON object
- Next by thread: Re: [tlug] My first JSON object [SOLVED]
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links