Hi guys, i've been struggling with something that i believe is a bug on this excellent library:
From the previous threads and the documentation, my understanding was that forms submitted through pjax are submitted with a content type set to "application/x-www-form-urlencoded".
However, if the form has a enctype set to "multipart/form-data", the pjax call is supposed to use this value and set the header Content-Type to this value.
I can't make it work on my server (Apache/PHP7) and despite the required enctype my data are sent as "application/x-www-form-urlencoded".
the formData is set properly, and using the debug mode, i can see that the reight object is used to pass the form data to my backend.
But when i look to the post request, the content-type is not changed, so my PHP script cannot handle the data properly.
find a the following capture describing what i believe is an issue :
Hi guys, i've been struggling with something that i believe is a bug on this excellent library:
From the previous threads and the documentation, my understanding was that forms submitted through pjax are submitted with a content type set to "application/x-www-form-urlencoded".
However, if the form has a enctype set to "multipart/form-data", the pjax call is supposed to use this value and set the header Content-Type to this value.
I can't make it work on my server (Apache/PHP7) and despite the required enctype my data are sent as "application/x-www-form-urlencoded".
the formData is set properly, and using the debug mode, i can see that the reight object is used to pass the form data to my backend.
But when i look to the post request, the content-type is not changed, so my PHP script cannot handle the data properly.
find a the following capture describing what i believe is an issue :




Hi @davidSocast, thanks for reporting this. Yes, looks like this is a bug as the Content-Type header is currently always set to "application/x-www-form-urlencoded" when submitting a form:
We'll look to fix this in the next release of the library.
Hi @davidSocast, thanks for reporting this. Yes, looks like this is a bug as the `Content-Type` header is currently always set to `"application/x-www-form-urlencoded"` when submitting a form:
https://github.com/MoOx/pjax/blob/e49d8947f7ca00254d09920784bcf8a3e4e16f2d/lib/send-request.js#L70-L73
We'll look to fix this in the next release of the library.
The fix for this should be simple: just add && !formData to the if statement. However, when I started writing tests for this, I ran into what I think is a bug in jsdom. So I'm going to wait until that's resolved to work on this.
The fix for this should be simple: just add `&& !formData` to the `if` statement. However, when I started writing tests for this, I ran into what I think is a [bug in jsdom](https://github.com/jsdom/jsdom/issues/2300). So I'm going to wait until that's resolved to work on this.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Hi guys, i've been struggling with something that i believe is a bug on this excellent library:
From the previous threads and the documentation, my understanding was that forms submitted through pjax are submitted with a content type set to "application/x-www-form-urlencoded".
However, if the form has a enctype set to "multipart/form-data", the pjax call is supposed to use this value and set the header Content-Type to this value.
I can't make it work on my server (Apache/PHP7) and despite the required enctype my data are sent as "application/x-www-form-urlencoded".
the formData is set properly, and using the debug mode, i can see that the reight object is used to pass the form data to my backend.
But when i look to the post request, the content-type is not changed, so my PHP script cannot handle the data properly.
find a the following capture describing what i believe is an issue :




Hi @davidSocast, thanks for reporting this. Yes, looks like this is a bug as the
Content-Typeheader is currently always set to"application/x-www-form-urlencoded"when submitting a form:https://github.com/MoOx/pjax/blob/e49d8947f7ca00254d09920784bcf8a3e4e16f2d/lib/send-request.js#L70-L73
We'll look to fix this in the next release of the library.
The fix for this should be simple: just add
&& !formDatato theifstatement. However, when I started writing tests for this, I ran into what I think is a bug in jsdom. So I'm going to wait until that's resolved to work on this.The issue I opened in jsdom has not had a response in 3 weeks, so I'm submitting the fix for this, and the tests will have to wait.