Display JSON Data in HTML Table

后端 未结 9 2129
既然无缘
既然无缘 2020-11-27 03:47

I get the following JSON String from server as response

[{\"city\":\"AMBALA\",\"cStatus\":\"Y\"},{\"city\":\"ASANKHURD\",\"cStatus\":\"Y\"},{\"city\":\"ASSA         


        
9条回答
  •  没有蜡笔的小新
    2020-11-27 04:22

    HTML:
     
    JS: $('#search').click(function() { $.ajax({ type: 'POST', url: 'cityResults.htm', data: $('#cityDetails').serialize(), dataType:"json", //to parse string into JSON object, success: function(data){ var len = data.length; var txt = ""; if(len > 0){ for(var i=0;i"+data[i].cStatus+""; $("#container").append(txt); } }, error: function(jqXHR, textStatus, errorThrown){ alert('error: ' + textStatus + ': ' + errorThrown); } }); return false; });

提交回复
热议问题