How can I make a redirect page in jQuery/JavaScript when using ajax?
16,438
Solution 1
$.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"! ;)
Solution 2
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";
}});
Related videos on Youtube
Comments
-
Anton Dimitrov over 1 year
How can I redirect the user from one page to another using jQuery -> Ajax? Thanks for your time.
-
putvande over 10 yearsWhat have you tried? And why do you want to do this? Why not just use a link to send the user to another page? Or are you already using AJAX to do something and want to send the user after the callback?
-
adeneo over 10 yearsUsing ajax to redirect is the exact opposite of it's intended use.
-