skip to Main Content
$(document).on('click','#edit',function(){
    var id = $(this).attr('value');
    
    $.ajax({
        type:'post',
        url:"http://localhost/CI-Ajaxold/register/show/"+id,
    }).done(function(data){
        console.log(data);
    });
});

RESPONSE IN CONSOLE => [{"id":"23","name":"fhfhfh",}]

2

Answers


  1. You need to parse the JSON response as below:

    $(document).on('click','#edit',function(){
                var id = $(this).attr('value');
                
                $.ajax({
                    type:'post',
                    url:"http://localhost/CI-Ajaxold/register/show/"+id,
                    
                }).done(function(data){
                 let response = $.parseJSON(data);
                 // here you can use response variable as needed. 
    
    
    
                });
            });
    

    Then you can use it by iterating loop or anything else as per your need.

    Thanks and hopefully it helps you!

    Login or Signup to reply.
  2. try this code:

    $.ajax({
        type:'post',
        url:"http://localhost/CI-Ajaxold/register/show/"+id, 
        success: function(result){
          //use result here
        }});
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search