Acutally I have a working AJAX Call that get me back after succeed to a static defined Site.
$.ajax({
url: 'myPage.php',
type: 'get',
data: {TestaufstellungID:TestaufstellungID, Datum: Datum},
dataType: 'text',
success:function(data){
window.location = "staticPage.php";
console.log('SQL Eintrag Erfolgreich Aktuallisiert');
},
error: function(jqxhr, status, exception) {
console.log(exception);
}
});
It works fine with window.location
but I want a dynamic site, back to this site where the use came from, like in PHP:
header('Location: ' . $_SERVER['HTTP_REFERER']);
Please don't give me answer like history.go(-1);
becasue I don't want cached sites. Should be do the same like the PHP code, because in some cases I need the page URL with all string (Get-Method
).
My reference Post, to understand the step by step page working order, I want to be back all in all to the first step (page) but this page is not always the same one.
https://stackoverflow.com/qs/56239790
I'm not certain I understand you completely. However...
$previous = "javascript:history.go(-1)";
if(isset($_SERVER['HTTP_REFERER'])) {
$previous = $_SERVER['HTTP_REFERER'];
}
For redirecting with PHP
header("Location: $previous");
For testing with a HTML link
<a href="<?= $previous ?>">Back</a>
I hope this is helpful.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With