Change window location Jquery

后端 未结 6 1766
Happy的楠姐
Happy的楠姐 2021-01-01 14:37

I am using ajax to load my website content and want to update the window location when ajax is successful.

How can I update the window location to \"/newpage\"?? I n

6条回答
  •  被撕碎了的回忆
    2021-01-01 15:12

    I'm assuming you're using jquery to make the AJAX call so you can do this pretty easily by putting the redirect in the success like so:

        $.ajax({
           url: 'ajax_location.html',
           success: function(data) {
              //this is the redirect
              document.location.href='/newpage/';
           }
        });
    

提交回复
热议问题