diff --git a/core-xhr.html b/core-xhr.html index 8557aec..058da39 100644 --- a/core-xhr.html +++ b/core-xhr.html @@ -71,21 +71,29 @@ } return xhr; }, - + toQueryString: function(params) { var r = []; for (var n in params) { var v = params[n]; n = encodeURIComponent(n); - r.push(v == null ? n : (n + '=' + encodeURIComponent(v))); + if(v == null){ + r.push(n); + }else{ + v = this.isString(v) ? v : JSON.stringify(v); + r.push(n + '=' + encodeURIComponent(v)); + } } return r.join('&'); }, - + isString:function(str){ + return str instanceof String || + typeof str === 'string'; + }, isBodyMethod: function(method) { return this.bodyMethods[(method || '').toUpperCase()]; }, - + bodyMethods: { POST: 1, PUT: 1, @@ -111,5 +119,5 @@ }); - + diff --git a/tests/html/core-ajax-arrays.html b/tests/html/core-ajax-arrays.html new file mode 100644 index 0000000..104d1c1 --- /dev/null +++ b/tests/html/core-ajax-arrays.html @@ -0,0 +1,47 @@ + + + + + core-ajax + + + + + + + + + + + + + + + + + diff --git a/tests/html/core-ajax-complexe-object.html b/tests/html/core-ajax-complexe-object.html new file mode 100644 index 0000000..bd07743 --- /dev/null +++ b/tests/html/core-ajax-complexe-object.html @@ -0,0 +1,44 @@ + + + + + core-ajax + + + + + + + + + + + + + + + + diff --git a/tests/html/core-ajax.html b/tests/html/core-ajax.html index 6f14152..3f63541 100644 --- a/tests/html/core-ajax.html +++ b/tests/html/core-ajax.html @@ -21,20 +21,38 @@ + auto> + + diff --git a/tests/js/htmltests.js b/tests/js/htmltests.js index 417604d..fb6a9df 100644 --- a/tests/js/htmltests.js +++ b/tests/js/htmltests.js @@ -1,3 +1,5 @@ htmlSuite('core-ajax', function() { htmlTest('html/core-ajax.html'); -}); \ No newline at end of file + htmlTest('html/core-ajax-complexe-object.html'); + htmlTest('html/core-ajax-arrays.html'); +});