Ich möchte die Seite umleiten, wenn die Bedingung innerhalb der Erfolg wird das Ergebnis der test.php Seite, die "no_errors" ist.Umleitung Seite nach Abfrage Ergebnis mit Ajax
Wenn die Seite test.php gibt mir eine Ausgabe von "keine Fehler", funktioniert die Umleitung Funktion nicht. Danke im Voraus.
$.ajax({
type: 'post',
url: 'test.php',
data: {user_name:tesseraval },
success: function (result) {
if(result === "no_errors") location.href = "ThankYou.html"
else $('#display_info').html(result);
}
});
test.php
<?php
try {
if (isset($_POST['user_name'])) {
$user = $_POST['user_name'];
$z = sprintf('%08d', $user);
include("conn/auth.php");
include("conn/db.php");
include("conn/restriction.php");
$query_string = "SELECT * FROM data WHERE user LIKE '%".$z."%' ;";
if ($result = $con->query($query_string)) {
if ($result->num_rows > 0) {
if ($result->num_rows > 1) {
echo " Attention! Duplicated ";
while ($row = $result->fetch_object()) {
echo '<table id="table" class ="table"><thead> <th> ID </th><th>Name</th><th> fullname </th></thead><tbody>';
echo '<tr><td id ="cod">'.$row->Code.'</td>';
echo '<td>'.$row->name.'</td>';
echo '<td>'.$row->fullname.'</td>';
echo '</tr></tbody></table>';
}
} else {
$query_string2 = " SELECT * FROM blacklist WHERE user = ".$z." ;";
if ($result2 = $con->query($query_string2)) {
if ($result2->num_rows < 1) {
echo "no_errors";
} else {
echo " BLACKLISTED cannot be used";
}
}
}
} else {
echo " NO RESULT ";
}
}
}
} catch (Exception $e) {
header('HTTP/1.1 500 Internal Server Error');
}
?>
'console.log (Ergebnis)' zeigt was genau? – CBroe
versuchen Sie es als 'window.location.href' –
Mögliches Duplikat von [Wie zu einer anderen Webseite umleiten?] (Https://stackoverflow.com/questions/503093/how-to-redirect-to-another-webpage) – Alexander