Hi Dane,
The correct behavior with CORS is to make a OPTIONS request first, so I
guess that the Angular behavior is correct.
If you read the $.ajax doc, you will see :
>
> For cross-domain requests, setting the content type to anything other than
> application/x-www-form-urlencoded, multipart/form-data, or text/plain will
> trigger the browser to send a preflight OPTIONS request to the server.
Check the "Content-Type" used with your "jquery-request", I guess that the
value is "application/x-www-form-urlencoded" ;)
*dataType * option will parse JSON received but will not set "Content-Type"
to "application/json".
Regards,
Charly.
Le mardi 15 juillet 2014 20:54:25 UTC+2, Dane Vinson a écrit :
>
> I'm performing cross-domain POST. In Angular it looks something like this:
>
> $http.post('https://somesite/api', formData)
> .success(function (data, status, header, config) {
> })
> .error (function (data, status, header, config) {
> });
>
> Examining the HTTP traffic with Fiddler I can clearly see the request is
> an OPTIONS type which you'd expect for cross-domain. However if I send the
> same data using Jquery the traffic shows only a POST. There's no pre-flight
> options request made at all.
>
> $.ajax({
> url: 'https://somesite/api',
> type: 'POST',
> data: formData,
> dataType: 'json',
> success: function (result, textStatus, jqXHR) {
> },
> error: function (jqXHR, textStatus, errorThrown) {
> }
> });
>
> Shouldn't both of these methods be making a pre-flight options request?
>
--
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.