Commit c761fb01 authored by Dries's avatar Dries

- Patch #673884 by casey, mfer: optimize Drupal.parseJSON.

parent 879eb7ef
......@@ -132,7 +132,7 @@ Drupal.ajax = function (base, element, element_settings) {
// Sanity check for browser support (object expected).
// When using iFrame uploads, responses must be returned as a string.
if (typeof response == 'string') {
response = Drupal.parseJson(response);
response = $.parseJson(response);
}
return ajax.success(response, status);
},
......
......@@ -247,18 +247,6 @@ Drupal.theme = function (func) {
return (Drupal.theme[func] || Drupal.theme.prototype[func]).apply(this, args);
};
/**
* Parse a JSON response.
*
* The result is either the JSON object, or an object with 'status' 0 and 'data' an error message.
*/
Drupal.parseJson = function (data) {
if ((data.substring(0, 1) != '{') && (data.substring(0, 1) != '[')) {
return { status: 0, data: data.length ? data : Drupal.t('Unspecified error') };
}
return eval('(' + data + ');');
};
/**
* Freeze the current body height (as minimum height). Used to prevent
* unnecessary upwards scrolling when doing DOM manipulations.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment