jqueryを使用したAJAXは初めてです。以下のようなjson応答があります。
[{"customer_name":"Customer A"},{"customer_name":"Customer B"},{"customer_name":"Customer C"}]
そして、私のajaxファイルは次のとおりです。
function(result){
$('#resdiv').html(result);
console.log(result);
var json_obj = $.parseJSON(result);//parse JSON
alert(json_obj);
var output="<ul>";
for (var i in json_obj)
{
output+="<li>" + json_obj[i].customer_name + "</li>";
}
output+="</ul>";
$('#resdiv1').html(output);
}
div id でJSON 応答を表示できますがresdiv
、div idresdiv1
は空です! またalert(json_obj);
、何も警告しません! ファイルの何が問題になっていますか?