i'm trying to start a php script after i press a button, and then reload the page, but i have a problem, now i do this:
<a href="#" class="btn green big" onclick="startUpdate();">Start Update</a>
then this is the script:
<script type="text/javascript">
function startUpdate() {
$.get("Update/startUpdateTxt.php");
return false;
}
</script>
these script write on a txt file, all works perfect but i want refresh the page because i have to change some element and read the change i make in the txt file, so i have tried to do this:
<script type="text/javascript">
function startUpdate() {
$.get("Update/startUpdateTxt.php");
return window.location.href=window.location.href;
}
</script>
in this way, the page is refreshed but the phpscript doesn't work anymore, and doesn't write anything in the file, this is the phpscript:
startUpdateTxt.php:
<?php
$myFile = "updateStatus.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = "StartUpdate
";
fwrite($fh, $stringData);
fclose($fh);
?>
how i can do to refresh the page and call in background the phpscript?