I have a code that looks like this:
jQuery.post("test1send.php", { browName : browser, timeCan: testTimeCanvas , timeSVG: testTimeSVG });
window.location.href = 'http://localhost/start/prosteTest2.html';
.php file looks like:
<?php
$browName = $_POST['browName'];
$timeCan = $_POST['timeCan'];
$timeSVG = $_POST['timeSVG'];
if($browName=='Opera'){
$rowsCount = count(file('Data\Test1\Test1Opera.csv'));
$fp = fopen('Data\Test1\Test1Opera.csv', 'a');
fwrite($fp, $rowsCount);
fwrite($fp, ',');
fwrite($fp, $timeCan);
fwrite($fp, ',');
fwrite($fp, $timeSVG);
fwrite($fp, "
");
fclose($fp);
}else if($browName=='Firefox'){
$rowsCount = count(file('Data\Test1\Test1Firefox.csv'));
$fp = fopen('Data\Test1\Test1Firefox.csv', 'a');
fwrite($fp, $rowsCount);
fwrite($fp, ',');
fwrite($fp, $timeCan);
fwrite($fp, ',');
fwrite($fp, $timeSVG);
fwrite($fp, "
");
fclose($fp);
}
?>
It should send variables to php and load next page. PHP should save variables to .csv file but it does not work. If there is no "window.location.href" it works fine but when there is command to go to next page PHP does nothing. Does it need some delay to do PHP first and then go to next page??