CodeIgniter Forums
Controller echo response to Ajax request. Wrong? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Controller echo response to Ajax request. Wrong? (/showthread.php?tid=55435)



Controller echo response to Ajax request. Wrong? - El Forum - 10-26-2012

[eluser]jefc[/eluser]
Hi,

Is it wrong to have a controller method which has been invoked by an Ajax request respond with a straight echo? Then the success function in the Ajax request shoves this into a user message div somewhere.

A tiny bit of background - am trying to mould Ion Auth's password change facilities into an Ajax context. Although the question is obviously general in nature.

Thanks in advance for any input.
Geoff


Controller echo response to Ajax request. Wrong? - El Forum - 10-26-2012

[eluser]PhilTem[/eluser]
Code:
$this->output->set_output();
is safer than an echo and the proper way of doing it!


Controller echo response to Ajax request. Wrong? - El Forum - 10-26-2012

[eluser]jefc[/eluser]
Ahh much more elegant. I should have worked that out for myself.

Thanks!