php - How does Codeigniter receive the ajax post data in controller -


i'm trying use codeigniter develop front-end client of project.

but ajax ci make me confused.

here ajax:

$.ajax({     url : "welcome/login"     type : "post",     datatype : "json",     data : {"account" : account, "passwd" : passwd},     success : function(data) {         //     },     error : function(data) {         //     } }); 

and controller:

public function login() {     $data = $this->input->post();     // can account , passwd array index     $account = $data["account"];     $passwd = $data["passwd"]; } 

now can account , password array index, how can convert received data object can property like: $data->account

thx!

change ajax this:

$.ajax({         url : "<?php echo base_url(); ?>welcome/login"         type : "post",         datatype : "json",         data : {"account" : account, "passwd" : passwd},         success : function(data) {             //         },         error : function(data) {             //         }     }); 

change controller this:

public function login() {     //$data = $this->input->post();     // can account , passwd array index     $account = $this->input->post('account');     $passwd = $this->input->post('passwd'); } 

i hope work you...


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -