Welcome Guest, Not a member yet? Register   Sign In
Ajax response: echo vs $this->output->set_output() vs exit($return_this)
#1

[eluser]mjsilva[/eluser]
So, what is the best thing to do here, in ajax call from a view, should a use echo or $this->output->set_output() in controller to show the ajax response?


edit: added exit($return_this) to title, thanks to Phil Sturgeon
#2

[eluser]rogierb[/eluser]
I always use echo(when not using another viewfile), seems much faster to let php handle this.
#3

[eluser]Phil Sturgeon[/eluser]
Using the output class is only useful if you are building up output as you go via view/parse files and the sort or for handling caching with shared logic.

If you are certain you want nothing else to be output, simply exit($return_this); to output and stop CI/PHP in its tracks. Much quicker.
#4

[eluser]mjsilva[/eluser]
Thanks for the answers.

@phil Sturgeon: didn't know about exit, going to start using it from now for my ajax responses.




Theme © iAndrew 2016 - Forum software by © MyBB