我从ajax调用php文件,但在set div #content中获取响应时遇到问题。一切都与苍蝇直接呼应着身体的开始。我也没有从ajax获得任何类型的错误状态。我做错了什么?
这是php文件:
if($_GET["id"]) {
$aPoem = $poems->find(array('language'=>($_GET["id"])));
foreach($aPoem as $poem) {
echo '<a href="index.php?id=' . $poem["_id"] . '" target="_self">' . $poem["title"] .'</a><br>';
}
}
Ajax文件:
function sendLanguage() {
jQuery.ajax({
url: "./ListTranslations.php",
method: 'GET',
contentType: 'application/json; charset=utf-8',
dataType: 'json',
}).done(function(response){
$('#content').html(response);
}).fail(function(error){
console.log(error);
});
}
非常感谢任何帮助!
编辑错字。
答案 0 :(得分:-1)
尝试innerHTML:
$('#content').innerHTML += response;