admin管理员组文章数量:1356326
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.
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./qs/56239790
Share Improve this question edited Jun 9, 2019 at 12:20 double-beep 5,53719 gold badges40 silver badges49 bronze badges asked May 25, 2019 at 12:15 DanielDaniel 6684 silver badges17 bronze badges 3- Why are you using AJAX at all? – Jared Smith Commented May 25, 2019 at 12:18
- Thats just one example Ajax Call. I need calls to the server without reloading. And i edit the post with my reference question to understand the Background. – Daniel Commented May 25, 2019 at 12:44
- Are you building a single page application? If yes, you should look into using a client-side router: github./krasimir/navigo. If not, why are you loading the previous page's html with an ajax call? – Neil VanLandingham Commented Jun 2, 2019 at 12:55
2 Answers
Reset to default 5 +50I'm not certain I understand you pletely. 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.
To Redirect to the Previous worked page.
window.history.back();
or
history.back();
It redirects to the previous page that we used to work. but when you want to redirect to the particular URL you can use that link in the href tag.
click Here for Reference the link tags
本文标签: javascriptBack to previous page in AJAX CallStack Overflow
版权声明:本文标题:javascript - Back to previous page in AJAX Call - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744006171a2574740.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论