Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

504
Views
How to trigger refresh on a page from another page (no redirect)?

So, what I have is a lot of pages like this, with GET parameters: benchmark.php?game_id=87 that display the information about the particular game (info is in a database) and also contains an Edit button.

The Edit button opens a new window using JS window.open("edit_game.php?game_id=87",...) The Edit window contains a few textboxes to add/modify data and a Save button.

The desired behaviour here is that when I press the Save button on the edit_game.php page, not only that the information is saved in the DB (this works) but also the benchmark.php?game_id=87 page is maybe refreshed so that the information displayed is actual. I don't know how to do the 'submit on page x, page y is aware and refreshes'.

I assume I should use AJAX for this but I don't know where to start. What I tried is something like this

setInterval( function(){
        $('#refresh_station').load('game_information.php');
    }, 2000);

that every 2 seconds it refreshes the information present in benchmark.php?game_id=87 but I find this very inefficient since it refreshes the info even if no modifications happened.

Is this the only way to approach this situation?

Edit: I should mention that edit_game.php?game_id=87 is not supposed to close or anything after pressing Save. So I can't just use the submit form to redirect back to benchmark.php.

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Yes you should use Ajax for it also add one field in Database table last_update, now when page edit_game.php?game_id=87 load it have last_update time, ajax check this last update on some interval time if ajax see there is any update page should be refreshed.

over 4 years ago · Santiago Trujillo Report

0

Running a loop that checks every few seconds whether the records have changed isn't the best solution in my opinion. There's a much easier way to trigger a page refresh when you submit a form in a popup window.

Using window.opener you can perform actions on the window that opened the popup that you're currently in. In your case:

<form onsubmit="window.opener.location.reload();">
Your form here.
<input type="submit" value="Save changes">
</form>

Or in jQuery:

$('form').submit(function() {
    window.opener.location.reload();
});
over 4 years ago · Santiago Trujillo Report

0

https://jsfiddle.net/yqv1eh8w/1/

postMessage

can communicate with the child window. Link

window.addEventListener("message", function (event) {});

will let you listen to it from a child window.

This should be help you with what you want. The entire thing communicates with the help of events and messages.

Also, you will need to run this locally (coz I opened popups to the same window)

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!