如何在 Java-Script 代码中加载 PHP-File?

How to load a PHP-File in Java-Script code?

您好,我有一个名为 test.php 的 PHP 文件。为此,我有以下代码:

  <body>
            function writeData(){
              
              firebase.database().ref("User").set({
              name: document.getElementById("nameField").value,
              age: document.getElementById("ageField")
              });

              ***Here the test.php file should be reloaded***
              }
              
            </script>
                <div class="box">
<center>            <div class="button">
                    
                        <button onclick = "writeData()"> Submit </button>

                    </div>
                </div>
</center>

 </body>

如何在 Javascript 代码中重新加载我的 test.php 文件? 我会很高兴得到答案

有刷新


 location.reload();

如果你想在不刷新的情况下加载文件,你应该使用Ajax

工作流程示例 jquery


$('#yourdiv_id').load('page.php');