简体   繁体   English

html刷新页面,无需再次发送表单数据(除了ajax)

[英]html refresh the page without sending form data again besides ajax

I have a form sending data via post to the page of itself. 我有一个通过邮寄将数据发送到自身页面的表单。 I want to refresh the page without sending form data again just like you go to the page initially.As far as I know I can use ajax to do so, but it is quite complicated. 我想刷新页面而无需再次发送表单数据,就像您刚进入页面时一样。据我所知,我可以使用ajax来执行此操作,但这非常复杂。 And, I am looking for simpler method to do so. 而且,我正在寻找更简单的方法来做到这一点。 I have searched overriding refresh but it is not possible. 我搜索了覆盖刷新,但这是不可能的。 So, do you have any methods refreshing the page without sending form data again besides ajax? 因此,除了ajax之外,您是否有其他方法可以刷新页面而无需再次发送表单数据?

my code of abc.php: 我的abc.php代码:

<html>
<body>
<?php
echo "<form action='abc.php' method='post'>";
if(isset($_POST["edit_u_name"])){
  echo "<br><br>name: <input type='text' name='user_name' maxlength='20' value='" .  $u_name . "'>  <input type='submit' name='confirm_u_name' value='confirm'><input type='submit' name='cancel_u_name' value='cancel'>";
}
else    
  echo "<br><br>name: ". $u_name. " <input type='submit' name='edit_u_name' value='edit'>";     

echo "</form>";
?>
</body>
</html>

When I press the edit button and then refresh, I want go to the page just like directly going to the page initially with sending data of edit button. 当我按下编辑按钮然后刷新时,我想转到页面,就像最初直接发送编辑按钮的数据进入页面一样。

Here you go 干得好

<!DOCTYPE html>
<?php
    if(isset($_POST["u_name"])){
        $u_name = $_POST["u_name"];
    } else {
        $u_name = '';
    }
?>
<html>
<body>
    <form action='abc.php' method='post'>
        <span id="in" style="display: none">
            <br>
            <br>name: <input type='text' name='u_name' maxlength='20' value='<?php echo $u_name; ?>'>
            <input type='submit' name='confirm_u_name' value='confirm'>
            <input type='reset' name='cancel_u_name' value='cancel'>
        </span>
        <span id="ed">
            <br>
            <br>name: <?php echo ($u_name =='')?'--':$u_name; ?><input type='button' value="Edit" 
                onclick="document.getElementById('ed').style.display = 'none';document.getElementById('in').style.display = 'block';">
        </span>
    </form>
</body>
</html>

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

相关问题 通过AJAX通过PHP发送表单,而无需刷新页面 - Sending form with PHP through AJAX with no page refresh 使用PHP AJAX显示成功消息而不显示页面刷新后,再次显示Form div - Show Form div again after displaying success message without Page Refresh Using PHP AJAX 停止发送ajax请求而不刷新页面 - Stop sending ajax request without page refresh 将数据从JS页面发送到没有表单或URL的HTML页面 - Sending Data from a JS page to an HTML page without Form or URL 使用Ajax将表单数据发送到Node.js而不重新加载页面 - Sending form data to nodejs without reloading page using Ajax 带有ajax的表单-没有刷新页面的消息表单php - form with ajax - message form php without refresh page 使用ajax提交表单将表单传递给php而不刷新页面 - Form submit with ajax passing form to php without page refresh 如何在不刷新页面的情况下发送表单数据? - How to send form data without page refresh? 如何在不刷新页面和 URL 路径的情况下使用 ajax 和 php 发送表单数据 - How to send form data using ajax and php without page refresh and URL path 通过 fetch 将数据发送到数据库,随后通过 fetch 再次将此数据显示到 html 页面,无需提交表单或刷新页面 - Send data to database via fetch and subsequently display this data to html page via fetch again without submitting form or refreshing the page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM