Search code examples
ajaxdrupaldrupal-6drupal-modulesahah

Any alternate of drupal_json for non-JSON output


In an AJAX call back in drupal it is normally recommended to use drupal_json() to send data to client. This function converts the raw data into JSON along with HTML encoding.

I want to send the HTML data without encoding to client. for this I am using following code:

print $html_output;
exit(0);

Is there any recommended or best way in drupal to do so?


Solution

  • If you need to output only the HTML output returned from the menu callback, then the following code is the correct one:

    print $html_output;
    module_invoke_all('exit');
    exit();
    

    If you want your output to appear together the blocks Drupal normally output, then the code needs to be changed to the following:

    return $html_output;