Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ajax call not working in IE 11 only

I have build a web application.It is working fine on every browser(Chrom,firefix,IE 7,8,9,10) but not 11 only.

here is the html :

<div class="menu_nav">
                <ul>
                    <li><a href="Upload.aspx">Upload</a></li>
                    <li class="active"><a id="btnSignIn" runat="server" rel="#div_Overlay" href="#">Sign in</a></li>
                </ul>
            </div>

here is overlay div code:

$("#btnSignIn").overlay({

        //    // some mask tweaks suitable for modal dialogs
        //    mask: {
        //        color: '#ebecff',
        //        loadSpeed: 200,
        //        opacity: 0.9
        //    },
        //    //effect: 'myEffect',
        //    closeOnClick: false,
        //});

Here is my ajax request:

$("#btnLogin").live('click', function () {
        if ($("#txtUserId").val() == "") {
            alert("User Id Required");
        }
        else if ($("#txtPassword").val() == "") {
            alert("Password Required");
        }
        else {
            $.ajax({
                url: "MainPage.aspx/CheckLogin",
                data: "{'UserId':'" + $("#txtUserId").val().trim() + "','Password':'" + $("#txtPassword").val().trim() + "'}",
                type: "POST",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (data) {
                    data = JSON && JSON.parse(data.d) || $.parseJSON(data.d);
                    if (data.Table[0].IsAllowed == "1") {
                        $("#btnSignIn").hide(function () {
                            var lblUserName = "<label class='lblWelcome'>Welcome, " + data.Table[0].UserFirstName + "<a id='btnlogout' href='#'>logout</label>";
                            $("#btnSignIn").parent().append(lblUserName);
                            $("#btnSignIn").overlay().close();
                        });
                        var v = window.location.search.replace("&msg=%27not%20logged%20in%27", "");
                        window.location.search = v;
                    }
                    else {
                        if (data.Table[0].IsVerified == "NotVerified") {
                            $("#txtPassword").val("");
                            $("#tr_Verify").show();
                        }
                        else {
                            $("#txtUserId").val("");
                            $("#txtPassword").val("");
                            alert("User Id Or Password Incorrect");
                        }
                    }

                },
                error: function (err) {
                    alert("Some error occured.Please contact to your administrator." + err);
                }
            });
        }
        return false;
    });

When I click login button , it simply goes to callback error. In all browsers everything is working fine. here is the url:

http://61.5.156.98/UPortal/MainPage.aspx

I also tried this :

error:function(xhr,err,exception){
    alert(xhr); //shows [object][object]
    alert(err);    //shows error
    alert(exception); //shows Internal server error
    });

Please help me out. The userId : 03211234567 pwd : 1234567 If someone has IE 11 then she/he can see the problem Thanks in advance.

like image 305
Adeel Shekhani Avatar asked Apr 02 '14 10:04

Adeel Shekhani


People also ask

Does Internet Explorer support Ajax?

Browsers that support web apps using Ajax:Microsoft Internet Explorer (IE) for Windows version 5.0 and above, with ActiveX enabled.


1 Answers

Add cache: false in your ajax call like this :

 $.ajax({
            url: "MainPage.aspx/CheckLogin",
            data: "{'UserId':'" + $("#txtUserId").val().trim() + "','Password':'" + $("#txtPassword").val().trim() + "'}",
            type: "POST",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            cache: false,
            success: function (data) {...
like image 66
Heisenberg08 Avatar answered Sep 25 '22 02:09

Heisenberg08