Side navigation
#197 closed feature (invalid)
Opened September 14, 2006 01:13AM UTC
Closed October 01, 2006 03:12PM UTC
Last modified March 15, 2012 07:19PM UTC
$.postJSON
Reported by: | cdomigan | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | |
Component: | ajax | Version: | |
Keywords: | json | Cc: | |
Blocked by: | Blocking: |
Description
A $.postJSON method would be handy.
Attachments (0)
Change History (5)
Changed October 01, 2006 03:12PM UTC by comment:1
resolution: | → invalid |
---|---|
status: | new → closed |
Changed October 10, 2006 03:54PM UTC by comment:2
Any example of it?
Changed October 24, 2006 08:06PM UTC by comment:3
keywords: | → json |
---|
I've used this script quite successfully:
http://www.thomasfrank.se/json_stringify_revisited.html
I have an app that stores data in a JSON object as a user is doing things. In order to get that JS object to the server to do something useful with it, it has to be converted to a string first. "JSONstring.make(myobject)" does just that. It's like Serialize, but for JSON.
I agree it would be useful to have build it, but I don't mind including an external script to do it.
Changed May 07, 2009 03:48PM UTC by comment:4
The problem with the workaround suggested by joern is that it doesn't actually enable you to POST (read: send) JSON. It simply allows you to send form data using post, and then receive JSON in return. A true postJSON function would let you send JSON. It would accept a javascript object in the "data" input and automatically:
# serialize it to a string
# set the content type to application/json (as specified in RFC 4627)
To actually support this, jquery would need to include a small JSON stringifier.
If you need this alot, you could just add it as a plugin:
This saves about 2 characters per use, not really that very handy...