weixin_33713707 2015-08-08 04:53 采纳率: 0%
浏览 3

CodeIgniter AJAX插入

I want to create photo tag using codeigniter I am referring this site (http://techlister.com/php/simple-photo-tagging-with-php-and-jquery/1176/) Data insertion is not working properly.It's a great help if you can help me to solve this issue.

here is my code

controller

public function addImageData()
    {
        $this->load->model('test_model');
        $this->test_model->insert_imageData();

    }

model

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')
        );

        $insert = $this->db->insert('image_tag', $data);
        return $insert;
}

view -code segment

 // 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().'Treatments_Controller/addImageData'; ?>",
                data: "pic_id=" + id + "&name=" + name + "&pic_x=" + mouseX + "&pic_y=" + mouseY + "&type=insert",
                cache: true,
                success: function(data){
                    //viewtag( id );
                    $('#tagit').fadeOut();
                }
            });

        });
  • 写回答

2条回答

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 使用自定义的类型代替内置类型可行吗
      • ¥15 关于STM32的SPI和ENDAT接口编码器通信的问题
      • ¥15 关于#pdfbox#生成的PDF文件正常,转图片中文乱码的问题,如何解决?
      • ¥15 ADS中有关DAC控件的使用问题
      • ¥15 win11如何运行geoserver
      • ¥15 审稿意见请教-用ERNIE进行小样本分类的对比实验问题
      • ¥15 gem5搭建arm v8
      • ¥15 安卓时间管理APP,怎么做
      • ¥15 这段有什么bug 为什么总报错
      • ¥15 Intel Realsense深度相机(D415/D435)拍摄梯子获取梯子点云