Skip to content

Commit

Permalink
Allow headers to be define globally (bugfix)
Browse files Browse the repository at this point in the history
  • Loading branch information
gre committed Feb 11, 2015
1 parent 79b244e commit 638f5dd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build/qajax.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 13 additions & 1 deletion src/qajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@
return (url.indexOf("?") === -1);
}

function cloneObject (obj) {
var clone = {};
if (obj) {
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
clone[key] = obj[key];
}
}
}
return clone;
}

function QajaxBuilder (urlOrSettings, maybeSettings) {
if (arguments.length === 0) throw new Error("Qajax: settings are required");

Expand All @@ -60,7 +72,7 @@
}

// Instance defaults (other defaults are extended by prototype)
this.headers = {};
this.headers = cloneObject(this.headers);
this.params = {};
for (var key in settings)
this[key] = settings[key];
Expand Down

0 comments on commit 638f5dd

Please sign in to comment.