Reputation: 51
How can I redirect the user from one page to another using jQuery -> Ajax? Thanks for your time.
Upvotes: 2
Views: 16457
Reputation: 100
// Through an HTTP redirect
window.location.replace("http://stackoverflow.com");
// Through by clicking on a link
window.location.href = "http://stackoverflow.com";
Upvotes: 0
Reputation: 695
$.ajax({
url:"http://where.to/redirect",,
async:false,
});
This will load the url synchroniously, that means redirect the user "in jquery/javascript when using ajax". To "make a redirect page", write this:
<script type="application/javascript" language="javascript">
$.ajax({
url:"http://where.to/redirect",,
async:false,
});
</script>
... tada! We have a "a redirect page in jQuery/JavaScript when using ajax"! ;)
Upvotes: 3
Reputation: 204
Try this if you want to redirect to another page once ajax call is success,
$.ajax({
url: "page1.html",
success:function(result){
document.location.href="page2.html";
}});
Upvotes: 3