Comments (3)
From coolaj86 on January 21, 2010 12:48:47
There's a jquery.cors plugin which I'm working on which also relies on jquery.json
and I have that method in there.
If you'd like to help, let me know.
from jquery-json.
From krinklemail on September 17, 2011 18:08:19
I'm not sure what the purpose of this function is intended to be.
jQuery has $.getJSON, which takes (url, data, success) and it makes a GET request to 'url' with data (which is an object, translated to a querystring like foo=bar&lorem=ipsum) and it parses the return value of the server (not the sending value of the client) as JSON and passes the parsed object into the success callback function.
A function named postJSON, in my opinion, would make a similar request but as POST, parsing the server return as JSON, not sending JSON to the server.
This seems a bit out of the scope of this plugin in my opinion. You could request the following to be added to jQuery though, in which case you can send JSON to the server in POST like this:
// in jQuery core
$.postJSON = function( url, data, callback ) {
return jQuery.get( url, data, callback, "json" );
}
// In your application
$.postJSON( 'awesome.php', { data: $.toJSON( ... ), function( response ) { ... } );
Status: WontFix
from jquery-json.
From benjamin.schweizer on September 18, 2011 03:09:38
From the reference implementation ( http://json.org/JSONRequest.html ):
"JSONRequest.post does an HTTP POST of a the serialization of a JavaScript object or array, gets the response, and parses the response into a JavaScript value. If the parse is successful, it returns the value to the requesting script. In making the request, no HTTP authentication or cookies are sent. Any cookies returned by the server cause the request to fail. The JSONRequest service can only be used to send and receive JSON-encoded values. JSONRequest cannot be used to retrieve other text formats."
From there, the proposed $.postJSON() function looks consistent to me, but it depends on a 3rd party library like jquery-json (or json2.js) to do the json encoding.
from jquery-json.
Related Issues (20)
- Reference toJSON and evalJSON directly to the native API if available HOT 1
- Inherited properties should be left out HOT 3
- Guard against object with own property "hasOwnProperty" HOT 2
- JSON is not defined on IE 9 compatibility mode HOT 4
- String should not be double escaped HOT 4
- triggering parseJSON unnecessarily? HOT 2
- No tags in the source repository HOT 2
- Spelling errors in code comments HOT 1
- Adding support for loading HOT 1
- A simple example how to use jQuery-JSON HOT 2
- Array detection should not use .constructor (broken in IE9) HOT 3
- Constructed/Instantiated primitives should be stringified like their primitive equivalants. HOT 2
- Dummy issue HOT 1
- Array named properties are not included in json string HOT 3
- o.constructor === Array return fails with frames. HOT 1
- Serialize arrays with a toJSON method
- Different result in deferent page HOT 1
- Switch to UglifyJS for minification
- add bower.json file HOT 2
- Invalid procedure call or argument HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquery-json.