Closed (fixed)
Project:
Drupal core
Version:
4.7.x-dev
Component:
javascript
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
16 Apr 2006 at 22:01 UTC
Updated:
8 Dec 2006 at 00:06 UTC
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 commentedI ran into this problem and this fix works.
Comment #5
dries commentedCommitted to CVS HEAD.
Comment #6
(not verified) commentedComment #7
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 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.