HI if every time you want to do the same thing as you said you can do that :
Library :
if($this->input->is_ajax_request())
{
$redirect_link = array("ajax_redirect_link" => TRUE);
header('Content-Type: application/x-json; charset=utf-8');
echo(json_encode($redirect_link));
exit;
}