首页 > 解决方案 > 问:加载新的 PHP 变量值而不刷新

问题描述

我想知道如何在分配 PHP 变量示例后加载或刷新它们:

<?PHP 
if(isset($_POST['rnd])){$post = $_POST['rnd'];}
?>

<input name='rnd' value='hey'> //insert any value
<?PHP if(isset($post)){?>
<div><h1><?PHP echo $post ?></h1></div><?PHP }?>

但是如果我这样做,我必须刷新页面以加载新值,所以我正在寻找如何在不刷新页面的情况下加载新值,我搜索了整个互联网并没有找到有用的结果,无论如何语言是什么,所以任何事情都会有所帮助。

标签: javascriptphpnode.jsbackend

解决方案


This question is a little vague. The answer depends on what you are trying to achieve and/or build.

  1. Is your form action set to current page or PHP_SELF
  2. Depending on what it is you are building you can create custom functions
  3. If all else fails check the documentation. Should not have a problem displaying user input data on form submission.
  4. Also, as was previously stated you could use AJAX.

推荐阅读