0
我很努力地使用codeigniter它創建的方式。我正在打開一個編輯頁面(訂單)。我想更改頁面上的數據,這些數據在離開字段後將被動態保存。但是,當我沒有成功的方式代言人的作品或與「好方法」的其他文字。我不想依賴於uri結構,並使用uri段獲取數據,就像現在的代碼一樣。我想下提高代碼但我沒有成功...遵循規則codeigniter使用codeiginiter和ajax
這是打開我的看法
public function edit($id = NULL) {
// Fetch a page or set a new one
$this->load->model('shop_m');
$this->load->model('details_m');
$this->data['subtitle'] = 'incoming';
if ($id) {
if($this->transfer_m->get_permission($id) > 0){
$this->data['transfer'] = $this->transfer_m->get_rec($id);
// $this->data['transfer'] = $this->transfer_m->get($id,true);
count($this->data['transfer']) || $this->data['errors'][] = 'page could not be found';
$this->data['details'] = $this->details_m->get_by(array('doc_no' => $id),FALSE);
}
else{
redirect('admin/Dashboard', 'refresh');
}
} else {
$this->data['transfer'] = $this->transfer_m->get_new();
}
$this->data['shop_from'] = $this->shop_m->get($this->data['transfer']->from_customer,TRUE);
$this->data['shop_to'] = $this->shop_m->get($this->data['transfer']->to_customer,TRUE);
// Load the view
$this->data['subview'] = 'pages/details/transfer_edit';
$this->load->view('pages/main', $this->data);
}
我的Ajax調用
function add_shop(shop){
var id = $('#doc_no').text();
$.ajax({
url: base_url+"/admin/transfer/add_shop/"+id+"/"+shop,
async: false,
type: "POST",
data: "",
dataType: "html",
success: function(data) {
$('#ajax-content-container').hide();
}
})
}
代碼我的控制器功能添加一個店鋪
public function add_shop($id){
$data = array('to_customer' => $this->uri->segment(5));
$this->transfer_m->save($data,$id);
}
任何幫助將不勝感激!
現在我覺得自己很蠢,這樣一個簡單的解決方案!謝謝! –