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.

CommentFileSizeAuthor
js-contenttypefix.patch328 bytesneilnz
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

michielnugter’s picture

I 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

michielnugter’s picture

Status: Needs review » Patch (to be ported)

The 7.x branch contains the fix, it still needs to be included in the 6.x branch. I'll apply the patch here soon.

michielnugter’s picture

Status: Patch (to be ported) » Closed (fixed)