What to return in controller |
Hello.
I would like to ask, what to return in controller if I am expecting XMLHttpRequest but request is not XMLHttpRequest. I have something like this: Code: public function show_post($id) Is it good to return false or return other value? Thank you.
If you accept the premise that a controller's ultimate purpose is to send output to browser then you need to decide what output is appropriate to the situation you describe.
One thought is to not do anything. PHP Code: public function show_post($id) Another thought is to return an error PHP Code: public function show_post($id) This produces a very sparse page showing only the error message. You could use CI's show_error function which outputs the standard error page. PHP Code: public function show_post($id) I would think the only questionable response is one that would give what is likely a hack attempt any clue as to why they got the output they did.
|
Welcome Guest, Not a member yet? Register Sign In |