CodeIgniter Forums
Ajax Cannot modify header information - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Ajax Cannot modify header information (/showthread.php?tid=6849)



Ajax Cannot modify header information - El Forum - 03-13-2008

[eluser]bpdp[/eluser]
Hi all,
I'm converting a PHP / Prototype website over to codeigniter, but I'm having trouble using Ajax. This is my first codeigniter project so I'm not really sure if I'm doing this right or not but... here goes.

My javascript calls functions that are in a model. the model uses an echo statement to output the (HTML) results. Which worked in the original site. The query works and the code works (as it updates the element that it should) but immediately following the results I get an error:

-------
Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at /Library/WebServer/Documents/ci/todo/src/application/models/user_scripts/selectormodel.php:45)

Filename: helpers/url_helper.php

Line Number: 487
-------

And yes I checked for whitespace. I have the url helper setup to autoload and prior to getting this error I was getting an error in my controller that I fixed. I guess I can't see why my controller or my url helper get loaded again with an asynchronous request.

any ideas on how I can fix this or a better way of setting up my code would be great.

Thanks


Ajax Cannot modify header information - El Forum - 03-14-2008

[eluser]dmiden[/eluser]
Try not to echo it out, but using a view and $this->load->view('view');


Ajax Cannot modify header information - El Forum - 09-07-2008

[eluser]Kenzie[/eluser]
I used
Code:
$this->output->set_output('data');
to fix this error/warning.


Ajax Cannot modify header information - El Forum - 09-07-2008

[eluser]phpoet[/eluser]
Might the problem be due to output buffering? In the main index.php file there is a call to ob_start() so you would probably need to call ob_flush() right after your echo statements if you were going to use echo.