Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
In parseJson() in drupal.js we test for the first character being { and, not finding it, raise an error. We need to allow the [ character too, since it's a valid JSON first character, and is sometimes generated by drupal_to_js().
Comment | File | Size | Author |
---|---|---|---|
drupal-json-char.patch | 660 bytes | nedjo | |
Comments
Comment #1
nedjoNot sure how I managed to assign this to 4.6.
Comment #2
drummI would like to see a review from Steven.
Comment #3
nedjoRecategorizing to javascript.
Comment #4
drob CreditAttribution: drob commentedI ran into this problem and this fix works.
Comment #5
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD.
Comment #6
(not verified) CreditAttribution: commentedComment #7
pasupathymahalingam CreditAttribution: pasupathymahalingam commentedI figured out that PHP 5.0 is introducing a \r and \n in the response..
Hence change the
/**
* All functions from here to end are temporary fixes to issues in drupal.js.
*/
/**
* Parse a JSON response.
*
* The result is either the JSON object, or an object with 'status' 0 and 'data' an error message.
*/
function parseJson(data)
{
TO
/* Trims leading and trailing spaces, \r and \n */
String.prototype.trim = function() { return this.replace(/^\s+|\s+$|^\r+|\r+$|^\n+|\n+$/, ''); };
/**
* All functions from here to end are temporary fixes to issues in drupal.js.
*/
/**
* Parse a JSON response.
*
* The result is either the JSON object, or an object with 'status' 0 and 'data' an error message.
*/
function parseJson(data)
{
data = data.trim(); // Trimming the data for space, \r and \n
Comment #8
Steven CreditAttribution: Steven commentedYou should not be getting blank lines added to your content. Most likely, you have an empty line at the end of some .php or .module file you edited.