I am trying to display ajax response output ,which is an array , it output is looking good in console.log ,but not getting displayed in resp div .
Here is jquery ajax code
index.php
$(document).ready(function(){
$("#demo").click(function(){
$.ajax({
url:"response.php",
type:"post",
data:{ "a":"a"},
success: function(obj){
var json = $.parseJSON(obj);
$.each(json,function(k,v){
$(".resp").html("<li>"+v+"</li>");
console.log("<li>"+v+"</li>");
});
},
error: function(error){
alert(error);
}
})
});
});
here is response.php
$a=array("1"=>"a","2"=>"b","3"=>"c","4"=>"d","5"=>"e","6"=>"f","7"=>"g","8"=>"h","9"=>"i","10"=>"j");
echo json_encode($a);
here is html
<div><button id="demo">Click me</button></div>
<div class="resp"></div>
$(".resp").append("<li>"+v+"</li>");instead of$(".resp").html("<li>"+v+"</li>");