I have a test that runs for a certain number of trials, and once finished, it posts the data to the PHP script. The data is successfully added to the database, but it does not echo out the results. I want the test results to be displayed for the user.
PHP
<?php
require_once 'php-includes/header.php';
include ('php-includes/phpValidate.php');
if ($_POST) {
include ('php-includes/antHelper.php');
$testData = removeDelimiters($_POST['RT'], $_POST['condition'], $_POST['response'], $_POST['ansStr'], $_POST['congruency'], $_POST['cueStr']);
$testID = addTest($_POST['toa'], $_POST['nTrial']);
if (isset($testID)) {
for ($i = 0; $i < count($testData["RT"]); $i++) {
addResponse((int)$testData["RT"][$i], (int)$testData["condition"][$i], $testData["response"][$i], $testData["answer"][$i], $testData["cue"][$i], $testData["congruence"][$i], $testID);
}
$results = getCueScores($testID);
$results = getCongruencyScores($testID, $results);
$alerting = $results["noCue"] - $results["doubleCue"];
$orienting = $results["centerCue"] - $results["spatialCue"];
$executive = $results ["incongruent"] - $results["congruent"];
echo 'Your alerting result is' . $alerting;
echo 'Your orienting result is' . $orienting;
echo 'Your executive result is' . $executive;
header('Location: index.php');
}
}
?>
JS
$(".btn[name=submitANT").click(function() {
$.post("antApp.php",
{response : $("input[name=rspStr]").val(), RT : $("input[name=RTStr]").val(), nTrial : $("input[name=nTrial]").val(), toa : $("input[name=toa]").val(),
condition : $("input[name=condition]").val(), ansStr : $("input[name=ansStr]").val(), cueStr : $("input[name=cueStr]").val(),
congruency : $("input[name=congruency]").val()},
function(data) {
//$("#antDebrief").show();
//$("#antDebrief").css("visibility", "visible");
});
});