Closed Gargaj closed 7 years ago
It won't work as you expect. Ajax.Base.initialize()
sets this.options.contentType
to 'application/x-www-form-urlencoded'. The only way to remove it completely is delete headers['Content-type']
in case it was specified by programmer
See my issue about the same problem
It does work (and I'm using it) because the options
object provided by the user extends (=overwrites) this.options
here: https://github.com/sstephenson/prototype/blob/master/src/prototype/ajax/base.js#L13
Note that I didn't say that the user shouldn't supply contentType
for this effect - they should explicitly set it to null
or false
!
OK, if it works. But you didn't take encoding
parameter in consideration - it won't be set if contentType
is not provided
...why wouldn't it (it does, the constructor loads the default if it's not set) and what does it matter? If contentType
is false, the encoding parameter is never used.
Just came across this issue myself. Hopefully this patch can be merged, otherwise there is no way to do Ajax requests that involve files.
It is worth noting that jQuery supports this by setting the contentType
to false
, so it would be nice if Prototype could also support this feature (as implemented by this PR.)
@savetheclocktower Sorry for the bump but any chance this can be merged? It is pretty low risk as it only adds a new way of specifying new behaviour and so won't change the way the code works for existing users.
Yeah, sorry. A new release is on my to-do list, and I'll make sure this is part of it.
Fantastic, many thanks :-)
Excellent!! Thank You!!
Fixed this in f63d7f7bb59bfa11adb21a79c3322a0f4d7ed7d3. Thanks!
This is crucial to be able to do proper
multipart/form-data
requests, otherwise theboundary
will never get filled correctly!With this patch if the user sets
contentType
to null/false, the actualContent-Type
header will be generated (correctly) by the browser.