Fix regression: default to JSON type on GET requests.

This commit is contained in:
Robin Ward
2013-05-07 17:16:13 -04:00
parent f9a82f3aa0
commit 6843ba7ed6
5 changed files with 131 additions and 90 deletions

View File

@ -231,10 +231,19 @@ Discourse = Ember.Application.createWithMixins({
var oldError = args.error;
args.error = function(xhr) {
// If it's a parseerror, don't reject
if (xhr.status === 200) return args.success(xhr);
promise.reject(xhr);
if (oldError) oldError(xhr);
}
// We default to JSON on GET. If we don't, sometimes if the server doesn't return the proper header
// it will not be parsed as an object.
if (!args.type) args.type = 'GET';
if ((!args.dataType) && (args.type === 'GET')) args.dataType = 'json';
$.ajax(Discourse.getURL(url), args);
});
},