2013-01-15 2 views
0
var trans = { 
    amount: $('#container input:first-child').val(), 
    note: $('#container input:last-child').val() 
    }; // javascript 

trans = { 
    "amount":"", 
    "note":"", 
} // json 

$trans = $this->input->post('trans'); 
$t = json_decode($trans); 

$amount = $t->amount; 
$note = $t->note; 

$this->form_validation->set_rules('amount', 'Amount', 'required'); 

오류는 JSON 개체를 확인하려면 어떻게해야codeigniter에서 json 객체의 유효성을 어떻게 확인합니까?

Call to a member function set_rules() on a non-object in...... 

입니까?

+1

당신이 뭘 하려는지 생성자에 form_validation 라이브러리를로드하려고? 당신이 따르고 있음을 확인하는 과정은 무엇입니까? –

답변

0

function __construct() { 
    parent::__construct(); 
    $this->load->library('form_validation'); 
}