OpenLayers.Format.GeoJSON throws an exception "SyntaxError: JSON.parse: unexpected ch

المشرف العام

Administrator
طاقم الإدارة
OpenLayers.Format.GeoJSON throws an exception "SyntaxError: JSON.parse: unexpected ch

In my GeoExt client, I have the following line that retrieves JSON data from a web service into a FeatureStore:

var store = new GeoExt.data.FeatureStore({ layer: route_layer, fields: [ {name: "length"} ], proxy: new GeoExt.data.ProtocolProxy({ protocol: new OpenLayers.Protocol.HTTP({ url: "./php/pgrouting.php", format: new OpenLayers.Format.GeoJSON({ internalProjection: epsg_900913, externalProjection: epsg_4326 }) }) }) });When this code is executed, Firebug reports the error SyntaxError: JSON.parse: unexpected character, even though the JSON returned by the web service is valid (I've confirmed this against http://jsonlint.com). The response header has been configured accordingly with the line header('Content-type: application/json',true);.

Anyone who might have encountered this issue before, please assist. I've waded around, but no luck yet.

UPDATE: Sample JSON output is at http://pastebin.com/LPLjBDgp. It's valid JSON, but the error SyntaxError: JSON.parse: unexpected character persists. I've even updated my html page by adding the following line in an attempt to restrict character encoding.



أكثر...
 
أعلى