Skip to content

Commit

Permalink
Merge pull request #15 from Timshel/ignore-undefined
Browse files Browse the repository at this point in the history
Ignore undefined parameters in serialize
  • Loading branch information
gre committed Feb 11, 2015
2 parents 5c9f29b + 0f6c15d commit 79b244e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions build/qajax.min.js

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

2 changes: 1 addition & 1 deletion src/qajax.js
Expand Up @@ -26,7 +26,7 @@
function serializeQuery(paramsObj) {
var k, params = [];
for (k in paramsObj) {
if (paramsObj.hasOwnProperty(k)) {
if (paramsObj.hasOwnProperty(k) && paramsObj[k] !== undefined) {
params.push(encodeURIComponent(k) + "=" + encodeURIComponent(paramsObj[k]));
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/qajax.js
Expand Up @@ -33,7 +33,7 @@ test("check the API needed for the test engine", function() {
ok(typeof Qajax.filterStatus=="function", "filterStatus exists");
ok(typeof Qajax.filterSuccess=="function", "filterSuccess exists");
ok(typeof Qajax.getJSON=="function", "getJSON exists");
equal(Qajax.serialize({ foo: 123, bar: "toto" }), "foo=123&bar=toto", "serialize works");
equal(Qajax.serialize({ foo: 123, bar: "toto", toto: undefined }), "foo=123&bar=toto", "serialize works (ignore undefined)");
});

asyncTest("simple Qajax.getJSON() successful", 1, function() {
Expand Down

0 comments on commit 79b244e

Please sign in to comment.