Skip to content

Commit ade8ee3

Browse files
committed
requests are always async
1 parent 3c404e1 commit ade8ee3

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

can-ajax-test.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,3 +722,32 @@ QUnit.test("beforeSend rejects the ajax promise on failure", function (assert) {
722722
assert.equal(reason, error, "error is what we expect");
723723
}).then(done);
724724
});
725+
726+
QUnit.test("async should be always true #51", function(assert){
727+
var done = assert.async();
728+
var headers = {},
729+
restore = makeFixture(function () {
730+
this.open = function (type, url, async) {
731+
assert.ok(async);
732+
};
733+
734+
this.send = function () {
735+
this.readyState = 4;
736+
this.status = 204;
737+
this.responseText = '';
738+
this.onreadystatechange();
739+
};
740+
741+
this.setRequestHeader = function (header, value) {
742+
headers[header] = value;
743+
};
744+
});
745+
746+
ajax({
747+
type: "get",
748+
url: "/ep"
749+
}).then(function () {
750+
restore();
751+
done();
752+
});
753+
});

can-ajax.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ function ajax(o) {
216216
if (!isPost && o.data) {
217217
url += "?" + (isJsonContentType ? JSON.stringify(o.data) : param(o.data));
218218
}
219-
xhr.open(type, url);
219+
xhr.open(type, url, true);
220220

221221
// For CORS to send a "simple" request (to avoid a preflight check), the following methods are allowed: GET/POST/HEAD,
222222
// see https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS#Simple_requests

0 commit comments

Comments
 (0)