Jump to content

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){
Edited by fluidsharp
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • 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.