Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery.ajax() reports invalid json - Firebug parses it fine
    text
    copied!<p>I have jQuery.ajax() creating a request to a url (cms2/docman/dir/%id) (%id is a numeric unsigned integer). The page requested runs some functions and outputs an array. This array is then run through <a href="http://api.drupal.org/api/function/drupal_json/6" rel="nofollow noreferrer">drupal_json</a>. drupal_json() echo's out the content first setting the header to </p> <p><code>Content-Type: text/javascript; charset=utf-8</code></p> <p>So far, everything seems to be going well. The functions are all running and the JSON is being outputted as expected. Through firebug it shows that the response received is JSON and offers the "JSON" tab to preview it. </p> <p>However, jQuerys jQuery.ajax() function says that a parser error occurred and that it returned "invalid" json. I copied out the json returned and tossed it into an editor (Eclipse PDT) but it shows that there are no errors. </p> <p>I'm completely stumped at this point. The only thing I can think of is if there is some kind of limit on the amount of text returned via this method. </p> <p><b>Creates the request:</b></p> <pre>function request(url) { $.ajax({ url: url, type: 'POST', dataType: 'json', async: false, success: function(data) { if(data.status) { docman.store = data.info; } else { docman.hideMessages(); docman.error(data.message); } }, error: function(data,ts,et) { docman.hideMessages(); docman.error(data); docman.store = data.responseText; } }); }</pre> <p>JSON output here - <a href="http://codetidy.com/102" rel="nofollow noreferrer">http://codetidy.com/102</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload