Welcome Guest, Not a member yet? Register   Sign In
output->set_header does not work in AJAX
#1

[eluser]tokyotech[/eluser]
Why does setting headers only work for a normal page, but not for an AJAX?

Code:
public MyClass extends Controller {
   // This loads a normal page. In Firebug, I look at the
   // page's headers in the net tab and I see "myParam" was
   // properly set.
   public function index() {
      $this->load->view('myView');
      $this->output->set_header('myParam: myValue');
   }

   // When I attempt to do the same for a request meant for
   // AJAX, it doesn't work. Firebug does not show "myParam"
   // When I inspect the headers in the console tab.
   public function ajaxAttemp1() {
      echo 'my text';
      $this->output->set_header('myParam: myValue');
   }

   // Here, I try to set the headers before I echo anything.
   // It still does not work.
   public function ajaxAttemp2() {
      $this->output->set_header('myParam: myValue');
      echo 'my text';
   }
}




Theme © iAndrew 2016 - Forum software by © MyBB