2013-01-15 66 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'); 

誤差如何驗證codeigniter中的json對象?

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

你如何驗證一個JSON對象?

+1

什麼是你想怎麼辦?驗證你的過程是什麼? –

回答

0

嘗試加載form_validation庫在構造函數

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