We help IT Professionals succeed at work.
Get Started

Redirection in Javacsript

3161 asked
Last Modified: 2014-05-02
I am doing an ajax call to a handler in C# and the handler is returning a successful response. I am try to direct the user to the proper url based on the response So the return value looks like this:

{'Auth':'true', 'URL':'Default.aspx'}

And the call looks like this:

$('#cmdSubmit').on('click', function () {

            var _username = $.trim($('#txtUsername').val());
            var _password = $.trim($('#txtPassword').val());
            var _formData = { 'func': 'Auth', 'Username': _username, 'Password': _password };

                url: _profileHdlr,
                async: false,
                type: 'GET',
                data: _formData,
                'dataType': 'json',
                success: function (data) {
                    alert(data.Url);     // Th alert fires just fine
                    window.location.href = data.Url;   // The window.location does nothing
                error: function (jqXHR, error, errorThrown) {
                    if (jqXHR.status && jqXHR.status == 400) {

Open in new window

I realize this seems simple, I think so also, but the redirection does not work. I already tried window,location.assign and .replace but nothing happens. If anyone has any ideas I would be grateful.
Watch Question
This problem has been solved!
Unlock 1 Answer and 10 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE