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条回答 默认 最新

  • 7*4 2015-08-08 11:22
    关注

    Change ur url like this

           url: "<?php echo base_url();?>Treatments_Controller/addImageData",
    
    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置