Skip to content
Advertisement

How can i refresh form after submit?

i have form like

<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>

for form submit i have used like

 $(document).ready(function() {

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

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

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

            });             

            return false;


        });

    });

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).

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

Advertisement

Answer

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

});

reloads the page by setting the href to the actual one 🙂

or you can also use this:

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

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.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement