我想在我的系统中添加照片标记功能。我参考了这个教程: http://techlister.com/php/simple-photo-tagging-with-php-and-jquery/1176/
我正在使用codeigniter框架,我想将其转换为codeigniter。但是这里的数据并没有保存在数据库中。请任何人帮我解决这个问题。这是我的代码:
视图-test_view.php:
// Save button click - save tagsfe
$( document ).on( 'click', '#tagit #btnsave', function(){
name = $('#tagname').val();
var img = $('#imgtag').find( 'img' );
var id = $( img ).attr( 'id' );
$.ajax( {
type: "POST",
url: "<?php echo base_url().'test_model/insert_imageData'; ?>", //model name
data: "pic_id=" + id + "&name=" + name + "&pic_x=" + mouseX + "&pic_y=" + mouseY + "&type=insert",
cache: true,
success: function(data) {
viewtag( id );
$('#tagit').fadeOut();
}
});
});
模型test_model.php:
public function insert_imageData()
{
$data = array(
'id' => $this->input->post('pic_id'),
'name' => $this->input->post('name'),
'pic_x' => $this->input->post('pic_x'),
'pic_y' => $this->input->post('pic_y')
);
$this->db->insert('image_tag', $data);
}
控权 ......................
public function addImageData()
{
$this->load->model('test_model');
$this->test_model->insert_imageData();
}