#197 closed feature (invalid)
$.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.
Change History (5)
comment:1 Changed 16 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:3 Changed 16 years ago by
Keywords: | json added |
---|
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.
comment:4 Changed 14 years ago by
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.
comment:5 Changed 14 years ago by
(Formatting Correction) 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)
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...