February 26, 2012

CodeIgniter forfeit default views

Question by JHollanti

I’m in the process of creating a quick “hack”. I’ve never used CodeIgniter before, so what i’m asking is probably pretty basic stuff.

I have a controller that outputs some JSON data. However, with the setup i’m working with comes a default view which creates some html to the end of the file and so, my JSON parser throws a fit. Is there a way to disable views altogether as i really don’t need a template file of any kind for this purpose?

Answer by Starx

You can simply use an exit() at the end of action to do this.

exit();

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!