javascript - 如何在 JavaScript 代码中加载 PHP 文件?
问题描述
您好,我有一个名为 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');
推荐阅读
- apache - 如何配置重写规则,即使在 URL 中使用别名,请求也会路由到服务器名称
- kubernetes - Rancher 错误目录远程提交检查失败:Repo
- django - 如何存储数据并在另一个视图中显示它们?姜戈
- html - 如何更改 iframe 内图像的样式
- shopify - 在 Shopify 产品页面上显示/隐藏 Afterpay 消息
- javascript - React Native Android Tv 控制嵌套 FlatList 中的焦点导航
- reactjs - TypeScript 中的上下文提供程序
- react-native - 如何将 Expo React 应用程序与排行榜和成就等“Google Play 游戏服务”集成?
- python - 有效字符验证
- python - Python中数据框中的日期总和