提交后如何刷新表格? [英] How can i refresh form after submit?

查看:154
本文介绍了提交后如何刷新表格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的表单类似

<form id="abc">
<div>
<select >
<option id= "1"> ha1 </option>
<option id= "1"> ha2 </option>
<option id= "1"> ha3 </option>
<option id= "1"> ha4 </option>
</select>
<input type="submit">
</div>
</form>

我使用过的表单提交

 $(document).ready(function() {

        $('#abc').submit(function(){

            $.post('filter.php', $(this).serialize(), function(data){

          $('#abc').reset();  //(this).reset();  

            });             

            return false;


        });

    });

此处重置不起作用.重置的任何问题我都没有. 提交表单后,我想用db值刷新表单(以显示刚刚选择的值).

Here reset is not working. Any problem with reset i am not getting. After form submit, i want to refresh form with db values (to display values selected just now).

提交或div刷新后如何刷新页面.

how can i refresh page after submit or either div refresh.

推荐答案

$(document).ready(function() {
    $('#abc').submit(function(){
        $.post('filter.php', $(this).serialize(), function(data){
        window.location.href=window.location.href;  
        });             
        return false;
    });

});

通过将href设置为实际页面来重新加载页面:)

reloads the page by setting the href to the actual one :)

或者您也可以使用:

parent.document.getElementById("abc").reload();

顺便说一句:我看不到您的服务器端代码,您必须呈现选定的值,当然,我假设您正在返回它们,我的答案并不涵盖服务器端场景.我的代码仅适用于您将选定的值保存到db后从服务器返回的情况.

by the way: i dont see your serverside code, you have to render the selected values, of course, i am assuming that you are returning them, my answer doesnot cover the serverside scene. my code is only for the case that you are returning the selected values from server after saving them into db.

这篇关于提交后如何刷新表格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆