jQuery: The Write Less, Do More JavaScript Library

Ticket #197 (closed feature: invalid)

Opened 2 years ago

Last modified 1 year ago

$.postJSON

Reported by: cdomigan Assigned to: anonymous
Type: feature Priority: minor
Milestone: Component: ajax
Version: Keywords: json
Cc: Needs:

Description

A $.postJSON method would be handy.

Attachments

Change History

Changed 2 years ago by joern

  • status changed from new to closed
  • resolution set to invalid

If you need this alot, you could just add it as a plugin:

$.postJSON = fuction(url, data, callback) {
	$.post(url, data, callback, "json");
};

This saves about 2 characters per use, not really that very handy...

Changed 2 years ago by imran@…

Any example of it?

Changed 2 years ago by bryan@…

  • keywords set to 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.

Note: See TracTickets for help on using tickets.