我有一个这样的 DIV <div id="message"></div>
并尝试使用 Ajax
向此 DIV 添加内容成功。
这是我的 ajax 代码的样子:
var data = $("form#password_forgotten").serialize();
$.ajax({
type: "POST",
url: "./includes/process_password.php",
data: data,
cache: false,
success: function (response) {
console.log(response);
$('#message').html(response);
}
});
但我无法填充#message
div 与此 ajax 响应。但是这个 ajax 编码对我有用,这是我可以得到的控制台。
<div class='alert alert-danger alert-dismissible' role='alert'>
<strong>Oops!</strong> Email address not recognised. Please try another.
</div>
谁能告诉我这是怎么回事?
谢谢。
最佳答案
根据评论中的对话
Now I found my #message DIV populating, but its hiding from my page. Like this - Oops! Email address not recognised. Please try another. ,
将答案总结为
填充 HTML 后添加 $('#message').show()
关于jQuery/Ajax 成功函数不呈现 html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31175742/