By cybermalandro on
I have a few functions in a module I wrote that use the print function in php to write javascript functions on my module. I tried to use the drupal_goto() function and I got the "warning: header information already sent by ...." I searched for answers on the web site and I tried all of the solutions which start to point the error to my print functions that write javascript on the module. So, how can I write javascript functions without using the print function and without having to screw my module functions. Anyone please? this message is really annoying.
Comments
long shot but try and remove
long shot but try and remove and spaces before and after you php tags
I am using now the
I am using now the drupal_set_html_head function to place references to some javascript.js files but there are some javascript functions that I need to write on the fly. What is the best way to do so? how can debug any other variables that might generate this header error message?
Do not 'print' from within a module
... unless you are rendering a menu callback with
print therm('page',$out);
Everywhere else you should be either returning the string, or (as you've found) using other API calls to put stuff places.
You can write dynamic js into your head too ---
Put a whole inline script block there.
http://www.coders.co.nz/
.dan. is the New Zealand Drupal Developer working on Government Web Standards
kewl
Kewl thanks! I appreciate the input