diff --git a/src/reqwest.js b/src/reqwest.js index 00e39a8..b950f4e 100644 --- a/src/reqwest.js +++ b/src/reqwest.js @@ -293,7 +293,7 @@ } catch (e) { // can't assign this in IE<=8, just ignore } - if (r) { + if (r || r == '') { switch (type) { case 'json': try { diff --git a/tests/fixtures/empty.html b/tests/fixtures/empty.html new file mode 100644 index 0000000..e69de29 diff --git a/tests/tests.js b/tests/tests.js index 663f1d7..cb56d65 100644 --- a/tests/tests.js +++ b/tests/tests.js @@ -351,6 +351,16 @@ }) }) + test('empty resp string is passed to callback', function (complete) { + ajax({ + url: '/tests/fixtures/empty.html' + , success: function (resp) { + ok(resp == '', 'resp object isn\'t empty string') + complete() + } + }) + }) + test('invalid JSON sets error on resp object', function (complete) { ajax({ url: '/tests/fixtures/invalidJSON.json'