Closed (won't fix)
Project:
JSON server
Version:
5.x-1.0
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
11 Feb 2008 at 21:51 UTC
Updated:
21 Sep 2011 at 15:41 UTC
Hi,
I'm trying to interact with drupal in javascript through json. When the response come back from the server, it is preceded by an empty line. The parsing of the response then fails at the following code in drupal.js:
Drupal.parseJson = function (data) {
if ((data.substring(0, 1) != '{') && (data.substring(0, 1) != '[')) {
return { status: 0, data: data.length ? data : 'Unspecified error' };
}
return eval('(' + data + ');');
};
The strange thing is that I had the same problem when I tried to use xmlrpc directly. So I guess the problem is there. I filled a bug there also. The other strange thing is that other peoples don't seem to have this problem. I'm using PHP 5.2.3 on Drupal 5.7 on Ubuntu 7.10. Nothing exotic there.
Anyway, I trimed the response in json_server.js at line 42 and everything work fine that way:
success: function(data) {
data = data.replace(/^\s+/, "");
parsed = Drupal.parseJson(data);
success(parsed['status'], parsed['data']);
I'll keep in touch if I find what that space is doing there.
Comments
Comment #1
skyredwang