Welcome Guest, Not a member yet? Register   Sign In
Ajax Cannot modify header information
#1

[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
#2

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

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

[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.




Theme © iAndrew 2016 - Forum software by © MyBB