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] Something's not right about my JSON
- Date: Sun, 15 Aug 2010 00:15:47 +0900
- From: David Shanahan <david@example.com>
- Subject: Re: [tlug] Something's not right about my JSON
- References: <4C6679EC.1010703@example.com> <AANLkTimDnUKt9g8R60znDe8rjW53d996AjGSXKOyyM3h@example.com> <4C668E86.2060904@example.com>
On Sat, Aug 14, 2010 at 8:11 PM, Dave M G <dave@example.com> wrote: > > I've tried creating this JSON sting using the following code (edited a > bit for brevity - hopefully no typos/syntax errors): > > var loginData=new Array(); I think you at least want a "new Object();", not "new Array():" An Object should be used for something containing named values, whereas an Array is for a plain list of items. > loginData.email=document.getElementById('email').value; > loginData.password=$.md5(document.getElementById('password').value); > userData=new Array(); here too, s/Array/Object/ > userData.login=loginData; > userData.newUserData="No"; > jsonString = JSON.stringify(userData); > $.post('jsonhandler.php', {JSON: jsonString}, checkResult, "json"); > But JSON is native to javascript so literal syntax is usually easier. You could just write something like: var userData = { "loginData" : { "email" : document.getElementById('email').value, "password" : $.md5(document.getElementById('password').value), }, "newUserData" : "No", }; $.post( 'jsonhandler.php', {JSON: JSON.stringify(userData)}, checkResult, "json");
- Follow-Ups:
- Re: [tlug] Something's not right about my JSON
- From: Dave M G
- References:
- [tlug] Something's not right about my JSON
- From: Dave M G
- Re: [tlug] Something's not right about my JSON
- From: Pier Fumagalli
- Re: [tlug] Something's not right about my JSON
- From: Dave M G
Home | Main Index | Thread Index
- Prev by Date: [tlug] Basic home-use firewall distro?
- Next by Date: Re: [tlug] Basic home-use firewall distro?
- Previous by thread: Re: [tlug] Something's not right about my JSON
- Next by thread: Re: [tlug] Something's not right about my JSON
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links