Jump to content


This topic is now archived and is closed to further replies.


jQuery.AJAX - Codeigniter second call is not executed.

Recommended Posts



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.





function test_contr(){

function test_delete($id){
   $output = NULL;
   foreach($data['query'] as $row){
      $output .= $row->id."<input class='del_picture' type='button' value='".$row->id."' name='id'>";
    echo json_encode($output);

not needed as there simple select id from database and delete

<!DOCTYPE html>
   <META http-equiv="Content-Type" content="text/html; charset=utf-8">   
   <script src="/script/jquery-1.9.1.min.js"></script>
<div class="result_table">
foreach ($query as $row){
   echo $row->id."<input class='del_picture' type='button' value='".$row->id."' name='id'>";

$(".del_picture").on("click", function(){
   var id =  $(this).attr("value");
     var myurl = '<?php echo base_url()."admin/main/test_delete/"?>';
    var url = myurl + id;
            url: url,
            dataType: 'json',
            success: function(update_html){

Share this post

Link to post
Share on other sites

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.