Releases: canjs/can-ajax
Should not error when loading if globals.location is undefined
Fixing package/main to work better with webpack/babel
2.4.5
Fix issue with multipart/form-data
uploads
This patch release fixes an issue where can-ajax
sets the incorrect Content-Type
header when the request payload is a FormData
instance.
For file uploads or where manually using FormData
in the can-ajax
request payload, DO NOT SET the Content-Type
header to multipart/form-data
. The browser will set the correct header and boundary.
Do this:
ajax({
url: "....",
type: "POST",
data: formData
});
Instead of this:
ajax({
url: "...",
type: "POST",
data: formData,
beforeSend(xhr) {
xhr.setRequestHeader("Content-Type", "multipart/form-data");
}
});
Replace `const` with `var`
Replaced single const
declaration with var
to match the rest of the code and fix a stealjs strict
error in iOS
QUNIT2 upgrade
This updates the tests to use [email protected].
Downgrade tests to ES5 syntax
The test suite for can-ajax threw syntax errors on IE11 due to the presence of ES6 arrow functions. StealJS does not automatically transpile to ES5 when using the CommonJS format as all CanJS sources do, so these function were being passed to the script engine unmodified.
This patch release does not involve changes to the can-ajax production code, and is primarily to ensure that the CanJS test suite runs smoothly on IE11.
Documentation cleanup
- Fix a link to jQuery’s docs
- Show importing from can
Support async: false
Some very old legacy code may be dependent on having synchronous AJAX. While we don't recommend using it for any current for future development, it is now supported in can-ajax. To use synchronous AJAX, the async
property must be explicitly set to false
.
For synchronous calls, Promises still resolve in microtasks as with asynchronous AJAX, but success
and error
callbacks passed as properties to ajax()
are resolved in thread. This means that success
and error
callback properties are now officially part of the public API as well. They were previously supported but undocumented.
Note: due to an error in versioning, 2.4.0 is the next revision published after 2.2.2, and there is no version 2.3.0.
Support async: false
Some very old legacy code may be dependent on having synchronous AJAX. While we don't recommend using it for any current for future development, it is now supported in can-ajax. To use synchronous AJAX, the async property must be explicitly set to false.
For synchronous calls, Promises still resolve in microtasks as with asynchronous AJAX, but success and error callbacks passed as properties to ajax() are resolved in thread. This means that success and error callback properties are now officially part of the public API as well. They were previously supported but undocumented.