jQuery/Ajax 成功函数不呈现 html

标签 jquery html ajax

我有一个这样的 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/

相关文章:

jquery - 基于过滤器隐藏元素

html - 在不使用表格的情况下让 HTML 中的文本元素占用固定大小的空间?

html - Bootstrap 表中标题下方的灰线

html 标签强而正确的做事方式?

jQuery 可以显式分配 .queue() length 属性吗?

javascript - 如何使用 Javascript 从外部 URL 获取 CSV 文件

jquery - 在下拉菜单上添加 mouseleave 延迟

javascript - XMLHttpRequest 返回无响应和 XML 错误

ajax - 通过 AWS SES 发送电子邮件批处理,有什么想法吗?

javascript - 如何在不使用 include() 的情况下从不同的 PHP 脚本访问变量