-
-
Save ntung/5706b2522181dcc960540c69c66631a8 to your computer and use it in GitHub Desktop.
Code Igniter // Detect and return AJAX / JSON response
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** 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