Arcadian
Arcadian

Reputation: 4350

MVC / jQuery FireFox and window.location not working

I have this block of code and in FireFox it doesnt seem to work

 SignIn: function () {

    $("#message-box").hide();

    var RememberMe = false;

    if ($('#RememberMe').is(':checked') == true) {
        RememberMe = true;

    }



    $.ajax({
        url: "/Home/AuthenticateUser",
        data: { UserEmail: $("#Login-UserEmail").val(), UserPassword: $("#Login-UserPassword").val(), RememberMe: RememberMe },
        type: "POST",
        success: function (data) {



            if (data != "") {
                $("#message-box").html(data);
                $("#message-box").slideDown();
            } else {

                  // alert("test") this dont fire either even though data ==""
            window.location.href = "/Dashboard/";
                  //tried window.location = "/Dashboard/"; not work either



            }

        },
        error: function (data) {
            alert(data);
        }
    });

},

Upvotes: 0

Views: 593

Answers (1)

Arcadian
Arcadian

Reputation: 4350

I have this block of code and in FireFox it doesnt seem to work

 SignIn: function () {

    $("#message-box").hide();

    var RememberMe = false;

    if ($('#RememberMe').is(':checked') == true) {
        RememberMe = true;

    }



    $.ajax({
        url: "/Home/AuthenticateUser",
        data: { UserEmail: $("#Login-UserEmail").val(), UserPassword: $("#Login-UserPassword").val(), RememberMe: RememberMe },
        type: "POST",
        dataType:"text",
        success: function (data) {



            if (data != "") {
                $("#message-box").html(data);
                $("#message-box").slideDown();
            } else {

                  // alert("test") this dont fire either even though data ==""
            window.location.href = "/Dashboard/";
                  //tried window.location = "/Dashboard/"; not work either



            }

        },
        error: function (data) {
            alert(data);
        }
    });

},

I needed to specify dataType:"text" for it to work in FF. In FF it returns [object object] when the data is ="" so when I did my check if (data!="") it is always true when in FF.

Upvotes: 1

Related Questions