Skip to content

Commit

Permalink
Permit setting extra headers as in jquery.ajax; bump version number
Browse files Browse the repository at this point in the history
  • Loading branch information
Lauri Svan committed Jul 2, 2014
1 parent b029049 commit 92cb595
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions lib/cheerio/ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,23 @@ function ajax(options) {
deferred = _deferred.Deferred(),
xhr = new XMLHttpRequest();

// Bind to XHR events
xhr.onreadystatechange = _.partial(handleStateChange,
deferred, extendedOptions);

// Disable the header check to permit extra headers
xhr.setDisableHeaderCheck(true);

// Open the connection
xhr.open("GET", options.url);
// Set request headers (if any)
if (typeof options.headers === 'object') {
for (key in options.headers) {
if (options.headers.hasOwnProperty(key)) {
xhr.setRequestHeader(key, options.headers[key]);
}
}
}
xhr.send(null);

return deferred;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "backbone-serverside-adapters",
"description": "Backbone replacements and DOM adapters for running it within node.js",
"version": "0.3.1",
"version": "0.3.2",
"author": "SC5 Online",
"homepage": "https://github.com/SC5/backbone-serverside-adapters",
"bugs": {
Expand Down

0 comments on commit 92cb595

Please sign in to comment.