0

I am invoking a void method by using JQuery ajax call as below:

var options = {

    url: "/Account/Login",
    data: formvalues,
    type: "post"
};

$.ajax(options).done(function () {

// how to redirect the user to home page?

});

I want to redirect the user to the home page after he is logged in. Is there a way to accomplish this in jQuery? I tried window.location.replace, but it simply displays the page without maintaining any history as such. Is there any other way to do it?

ataravati
  • 8,891
  • 9
  • 57
  • 89
Sam
  • 4,302
  • 12
  • 40
  • 74

3 Answers3

0

You should be a able to set window.location

window.location = '/Home/Index';

To clarify:

Though Window.location is a read-only Location object, you can also assign a DOMString to it. This means that you can work with location as if it were a string in most cases: location = 'http://www.example.com' is a synonym of location.href = 'http://www.example.com'.

https://developer.mozilla.org/en-US/docs/Web/API/window.location

beautifulcoder
  • 10,832
  • 3
  • 19
  • 29
0
// similar behavior as clicking on a link
window.location.href = "http://stackoverflow.com";

Answer found here.

Community
  • 1
  • 1
NightOwl888
  • 55,572
  • 24
  • 139
  • 212
-1

use windows.location.href instead

Vaibhav J
  • 1,316
  • 8
  • 15