2016-03-19 16 views

cevap

2

$(document).ready(function() { 
 
    $('#option1').click(function() { 
 
    $.ajax({ 
 
     url: '<?php echo base_url(); ?>' + 'main/studentdetails', 
 
     dataType: "JSON", 
 
     type: "POST", 
 
     success: function(retdata) { 
 
     $.each(retdata, function(i, item) { //i = number of records 
 
      $(".target").html(retdata[i].email); 
 
     }); 
 
     } 
 
    }); 
 
    }); 
 
});
<body> 
 
    <input type="button" id="option1"> 
 
    <div class='target'> 
 
    </div> 
 
</body>

aksi takdirde bir önceki değer ve son değer gösterilir yerini alacak, append() yerine html() kullanımı gerekir.

$(".target").append(item.email); 
İlgili konular