getJSON
. It could be easily presumed to just get (in the colloquial sense) a JSON object. It doesn't. It uses the HTTP GET
method.As it turns out, it is just a rebadge of the more generic
GET
.$.getJSON( url , query_object , function( data ) { ... } ) ;
Is equivalent to this.
$.get( url , query_object , function( data ) { ... } , 'json' ) ;
And, of course, this is generic. If you want to
POST
and get JSON back, you do this.$.post( url , query_object , function( data ) { ... } , 'json' ) ;
But they will not not not not NOT do this.
$.postJSON( url , query_object , function( data ) { ... } ) ;
Because that function name assumes you've put together a JSON object and are posting it, not downloading it with the
POST
method.Assuming that I was just getting JSON and not
GET
ting JSON, as jQuery seems to want me to assume, has caused me several days of problems. Am I right in thinking that their rational encourages people to have problems?
No comments:
Post a Comment