Question : Reloading a php page with javascript

I have a php page that uses javascript and saves form data to a mysql database.

When the user hits 'save' a javascript function is called.
the function runs a php page/script to delete some mysql info
then it runs another php page/script to append some mysql info

the last line of the function has:
window.location.reload()

The reason i added this line is that it refreshes some of the form data, for example reformatting numbers as percentages or adding commas and also recalculates some of the percentages since presumably the user has changed values that require this recalc.

Problem is that when i added the reload() line, the form would reload itself based on the version of the page that was first loaded, not the state it was in after the user changed some numbers and hit save

when i add a line
 alert("Data Saved!!");
before the reload() line, the page reloads properly now (with the users edits)

what is happening here and how do i get the page to reload with the users edits without the alert box being necessary?

Answer : Reloading a php page with javascript

NP,

Try replacing window.location.reload()

with

setTimeout('window.location.reload()',2000);

let me know what ya get :)

Random Solutions  
 
programming4us programming4us