javascript - How do I call a function within ajax using codeigniter to update -
i want call model function within ajax update data should in database.
my main function controller:
function m_addr(){ $this->load->view('m_add_view'); }
this other function in controller 1 want call m_add_view edit data in database ajax while remaining in m_add_view.
what thinking should execute function m_update without leaving m_add_view view not have reload page.
function m_update($id, $text, $column_name){ $data = array('text'=>$text); $this->db->where('id', $id); $this->db->update($column_name, $data); }
this code have far update is:
function edit_data(id, text, column_name){ $.ajax({ url:"<?php echo base_url(); ?>control/m_update", method:"post", data:{ id:id, text:text, column_name:column_name }, datatype:"text", success:function(data){ /*alert(data);*/ $('#infomsg').show(); } }); }
i want know how send id, text , colum_name m_update function update database behind scenes.
figured out how update it.
function m_update(){ $id = $this->input->post('id'); $text = $this->input->post('text'); $column_name = $this->input->post('column_name'); $data = array($column_name => $text); $this->db->where('id', $id); $this->db->update('table_name', $data); }
Comments
Post a Comment