fluidsharp Posted August 8, 2013 Share Posted August 8, 2013 Hi, I have issue with deleting data via jquery/ajax. First delete execute and data on page changed. But then when I click on next element for deleting, nothing happens. To avoid complicated code I wrote simple example which demonstrate issue. Controller function test_contr(){ $this->load->model('admin/Product_crud'); $data['query']=$this->Product_crud->test_model_select_data(); $this->load->view('admin/test',$data); } function test_delete($id){ $output = NULL; //var_dump($id); $this->load->model('admin/Product_crud'); $this->Product_crud->test_delete($id); $data['query']=$this->Product_crud->test_model_select_data(); foreach($data['query'] as $row){ $output .= $row->id."<input class='del_picture' type='button' value='".$row->id."' name='id'>"; } echo json_encode($output); } Model not needed as there simple select id from database and delete View <!DOCTYPE html> <html> <head> <META http-equiv="Content-Type" content="text/html; charset=utf-8"> <script src="/script/jquery-1.9.1.min.js"></script> </head> <body> <div class="result_table"> <?php foreach ($query as $row){ echo $row->id."<input class='del_picture' type='button' value='".$row->id."' name='id'>"; } ?> </div> </body> </html> <script> $(".del_picture").on("click", function(){ var id = $(this).attr("value"); var myurl = '<?php echo base_url()."admin/main/test_delete/"?>'; var url = myurl + id; $.ajax({ url: url, type:'GET', dataType: 'json', success: function(update_html){ $(".result_table").html(update_html); } }); }); </script> Link to comment https://forums.phpfreaks.com/topic/280956-jqueryajax-codeigniter-second-call-is-not-executed/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.