I think by doing $http.put(url, {data: {foo: 'baz bar'}}), you were 
confusing it with how $.ajax(<object>) is used?

With $.ajax(…), the function is invoked with an object, the keys of which 
contain the method, data etc.
That is different with $http(…) or $http.<method>(); since ofcourse, here 
we pass all of the same *keys *as in the object we pass to $.ajax(…), but 
as method parameters.

On Friday, 22 August 2014 23:35:05 UTC+2, Eric Eslinger wrote:
>
> If you call $http() directly on an options object, and you want to send 
> data (put or post), the data you're sending needs to go into a data: 
> attribute on the options object.
>
> If, however, you call $http.put(url, options), the options object is sent 
> as if it were the data: attribute of the $http() options block.
>
> IOW, if you do $http.put(url, {data: {foo: 'baz bar'}}), your endpoint 
> will receive {data: {foo: 'baz bar'}}, but if you do $http({url: url, 
> method: 'PUT', data: {foo: 'baz bar'}}), your endpoint will receive {foo: 
> 'baz bar'}. To make things equal, you should instead do a $http.put(url, 
> {foo: 'baz bar'})
>
> That drove me 100% batty, I was getting occasional 400 malformed errors as 
> Joi was barfing on server-side validation. It also seems to be contrary to 
> the documentation. (I'm on angular 1.2.20)
>
> e
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to