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.
It seems that there is no attempt to set a content type, just the following code is run to output JSON:
print drupal_to_js($return);
Sending JSON with text/html headers will cause some browsers (such as Chrome) to raise warnings in their error logs that the wrong content type was used for Javascript.
In Drupal 6, there's a utility function available in common.inc to return JSON with the proper headers, drupal_json().
The attached patch swaps out drupal_to_js() with drupal_json() to write the correct headers.
This doesn't affect functions that take care of their own JSON output, or other content type output.
Comment | File | Size | Author |
---|---|---|---|
js-contenttypefix.patch | 328 bytes | neilnz |
Comments
Comment #1
michielnugter CreditAttribution: michielnugter commentedI included this patch in the Drupal 7 release of js_callback as I now use the default drupal methods for this.
http://drupal.org/project/js_callback
Comment #2
michielnugter CreditAttribution: michielnugter commentedThe 7.x branch contains the fix, it still needs to be included in the 6.x branch. I'll apply the patch here soon.
Comment #3
michielnugter CreditAttribution: michielnugter commented