PolymerElements / iron-ajax

Easily make ajax requests
https://www.webcomponents.org/element/PolymerElements/iron-ajax
127 stars 113 forks source link

Two requests when set the content-type property #230

Closed abdonrd closed 7 years ago

abdonrd commented 8 years ago

Description

Everything works well without content-type property. Demo: https://jsbin.com/woreken/edit?html,output

screen shot 2016-09-07 at 15 18 33

But if I set the content-type property to application/json we have two requests (POST and OPTIONS): Demo: https://jsbin.com/lehudas/edit?html,output

screen shot 2016-09-07 at 15 18 22

Expected outcome

Only one request.

Actual outcome

Two request.

Live Demo

https://jsbin.com/nocuhuzuji/edit?html,output

Browsers Affected

stramel commented 7 years ago

@abdonrd I'm only seeing 1 request in Chrome when I try all 3 links provided. Although, with the first request being OPTIONS I would guess that it was a CORS preflight request. The defaulted application/x-www-form-urlencoded Content-Type shouldn't trigger a CORS preflight.

https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS#Preflighted_requests

abdonrd commented 7 years ago

Oh! Right now I only see one request. Closing...