php - Codeigniter and ajax post -



php - Codeigniter and ajax post -

i create ajax phone call codeigniter controller.

when controller inquire database , homecoming json result, no problem, when seek access method in same controller, have internal 500 error.

this working method:

public function test(){ $query = $this->db->query("select * database order name desc"); $data = $query->result(); echo json_encode($data); }

this when have internal 500 error:

public function test2(){ $query = $this->db->query("select * database order name desc"); $data['query'] = $query->result(); $data['test3'] = $this->test3(); echo json_encode($data); } public function test3(){ $testarray = array( 'first' => array( 'name' => 'john', 'code' => '376' ), 'ae' => array( 'name' => 'mike', 'dial_code' => '971' ), 'second' => array( 'name' => 'joe', 'code' => '93' ), 'third' => array( 'name' => 'emily', 'code' => '168' )); homecoming $testarray; }

so, how can prevent error?

edit: error message: fatal error: using $this when not in object context in

php jquery ajax arrays codeigniter

Comments

Popular posts from this blog

model view controller - MVC Rails Planning -

ruby on rails - Devise Logout Error in RoR -

html - Submenu setup with jquery and effect 'fold' -