lch
lch

Reputation: 27

Refreshing parent page after child FORM close

Currently I have a pop up form they shows a list of data, and I wished to refresh the parent page after the user closes the pop up form. I have look at a few stackoverflow examples and mostly is asking me to use window.onunload = refreshParent; function refreshParent() { window.opener.location.reload(); }

But I tried using those codes in my files and it didn't work. Anyone got any other method or anyone can guide me which part should I enter my code into.

HTML

<div id="login_form">
<table border=1>
<tr>
<th>Stages</th>
<th>Payment Percentage</th>
<th>Pay</th>
</tr>

<tr>
<td id="milestone_1"> 
</td>
<td id="percentage_1">
</td>
</tr>

<tr>
<td id="milestone_2">
</td>
<td id="percentage_2">
</td>
</tr>

<tr>
<td id="milestone_3">
</td>
<td id="percentage_3">
</td>
</tr>

</table>
<div class="err" id="add_success"></div>
<input type="button" id="cancel_hide" value="Close" />
</div>

JS

$(document).ready(function(){
$(".login_a").click(function(){
    $("#shadow").fadeIn("normal");
    var test = $(this).attr('data-id');
    var topost = 'getMilestoneDetail.php='+test;
    var returnResults = $.getJSON('getMilestoneDetail.php?id='+test,function(data)
    {
        var m1 = (data.mileStone1);
        var m2 = (data.mileStone2);
        var m3 = (data.mileStone3);

        if(m1 != ''){
        $("#milestone_1").html(data.mileStone1);
        $("#percentage_1").html(data.percentage1);
        } 
        if(m2 != ''){
        $("#milestone_2").html(data.mileStone2);
        $("#percentage_2").html(data.percentage2);
        } 
        if(m3 != ''){
        $("#milestone_3").html(data.mileStone3);    
        $("#percentage_3").html(data.percentage3);
        } 
    });
     $("#login_form").fadeIn("normal");
     $("#user_name").focus();
});
$("#cancel_hide").click(function(){
    $("#login_form").fadeOut("normal");
    $("#shadow").fadeOut();
});
});

Upvotes: 0

Views: 309

Answers (1)

Bla...
Bla...

Reputation: 7288

If you simply want to reload your page when user clicks the close button then you can do something like this:

$("#cancel_hide").click(function(){
    $("#login_form").fadeOut("normal");
    $("#shadow").fadeOut();
    location.reload(true); //true, so it will not reload the page from browser cache
});

Note: I assume #cancel_hide is the button that is used close the pop-up..

Upvotes: 1

Related Questions