drupal_json returns malformed JSON in Drupal 6. That was good, until jQuery 1.4, when it got strict about parsing JSON.
It should be used PHP function json_encode, but it's only present since PHP 5.2. So there is not easy fix for this problem for the maintainers, but anyway I posted here in case someone else is having problems with this.
At the end of shoutbox_js_view(), put this instead of drupal_json and return
drupal_set_header('Content-Type: text/javascript; charset=utf-8');
echo json_encode(array('success' => TRUE, 'data' => $output));
exit;
Also works with
drupal_set_header('Content-Type: text/javascript; charset=utf-8');
And other thing that used to work for me before when having problems with AJAX (but seems not now in jQuery 6.4) is telling to jQuery the dataType "text json", instead of "json"... so it will parse it for you.
See http://api.jquery.com/jQuery.ajax/
Comments
Comment #0.0
corbacho commentedUpdated
Comment #1
vitalblue commented