1

<script>
$('#showselectedpages').on('click','#editselection',function(e){
 //alert('edit');
 e.preventDefault();
 var id =$(this).val();
 var company=$('#cname').val();
 $.ajax({
 type:'POST',
 url:'mainquery_files/showselection.php',
 data:{mode:"showsingledata",company:company,id:id},
 success:function(data){  
 var parsed = $.parseJSON(data);
 $('#field1').attr('value',parsed.category);
 $('#field2').attr('value',parsed.display_name);
    
     $.ajax({
                        type: 'post',
                        url:'selectPage.php',                        
                        data: {depart:parsed.category},
                        success:function(response){ 
//alert(data);      
                          $('#page_name').empty();
                              var parsed = $.parseJSON(response);
                              $.each(parsed,function(i,parsed){                             
                         $('#page_name').append($('<option/>',{ value: parsed.pages, text: parsed.pages }));
                              });
                         }
      
     });
  
 $('#privilage').attr('value',parsed.privilage);
 $('#hidid').attr('value',parsed.id);
 $("#field1").attr('readonly','readonly'); 
 
 }

 });
 
});


 });
 
});
<script>
I am a beginner in javascript. This is the code for editing the form.I have to refresh the page after editing. How could i accomplish this? .I tried a lot but window doesn't refreshed.
jes
  • 27
  • 1
  • 1
  • 10
  • 1
    Possible duplicate of [How to reload a page using JavaScript?](https://stackoverflow.com/questions/3715047/how-to-reload-a-page-using-javascript) – kchason Dec 04 '17 at 12:54
  • Why refresh after doing AJAX data processing? – kchason Dec 04 '17 at 12:54

4 Answers4

0

You need to use location.reload(); in your success code/wherever you want to refresh

Tushar Walzade
  • 3,737
  • 4
  • 33
  • 56
0

JavaScript provides a handy function called reload on to the location object, you can use it like this:

window.location.reload()
Daksh M.
  • 4,589
  • 4
  • 30
  • 46
0

You can use location.reload() to refresh the page

Aditya Dan.
  • 108
  • 8
0

You can use location.reload() after successful submission of the form. If you just want to empty all fields you can use var anyField= "";

Anand Vaidya
  • 609
  • 2
  • 16
  • 41
  • I don't have your code sample. But you must have to after the successful submission of the form, where you are getting success. The above code just reloads the page and nothing else so wherever you put it will reload it. – Anand Vaidya Dec 04 '17 at 13:32