简体   繁体   English

加载网页后更新 HTML 内容而不重新加载

[英]Update HTML content after a webpage has been loaded without reload

I'm using php and jquery and trying to get a notification to appear after a user submits a form.我正在使用 php 和 jquery 并尝试在用户提交表单后显示通知。 I'm using ajax for the form submission so that the page does not reload.我正在使用 ajax 进行表单提交,以便页面不会重新加载。 I want the notification to contain some of the information from the form so they know if it has been entered already.我希望通知包含表单中的一些信息,以便他们知道是否已经输入。 The notification is just a hidden div that is shown when the ajax data is sent.通知只是一个隐藏的 div,在发送 ajax 数据时显示。 Is there any PHP statements or something in javascript or JQuery that can do this? javascript 或 JQuery 中是否有任何 PHP 语句或其他内容可以做到这一点?

Use ajax like this:像这样使用 ajax :

ajaxCall("formHandler.php", yourForm);

function ajaxCall(url, postData){

$.ajax(url, {
        dataType: "json",
        method: "post",
        data: {postData}
        success: function(data) {

        // your Code, example:
           document.getElementById("yourDIV").style.display="block";

    });
return true;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM