Skip to content

Instantly share code, notes, and snippets.

@olivierobert
Created November 22, 2012 09:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save olivierobert/4130171 to your computer and use it in GitHub Desktop.
Save olivierobert/4130171 to your computer and use it in GitHub Desktop.
Code Igniter // Detect and return AJAX / JSON response
/** Within the controller method **/
// If this is an ajax request, then return a JSON string
if ( $this->input->is_ajax_request() ):
$this->output->set_content_type('application/json');
$this->output->set_output( json_encode($data) );
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment