Click here to Skip to main content
15,896,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Below javascript function uploads the chosen file and updates the grid. Its working perfectly in firefox and chrome but not in IE11. Observed that its not executing "ESignature/Registration" function in onreadystatechange. I kept break point at Registration function. Its not getting hit and not refreshing the grid.

Surprisingly, its working when I open the Debugger by pressing F12 in IE. If I close it, again its not working. Something strange
Please guide me to fix this problem.

JavaScript
$("#lnkAddAttachment").click(function (e) {
            if (document.getElementById("txtFile").files[0] != null) {
                oFiles = document.getElementById("txtFile").files[0];
                nFiles = oFiles.size;

                var selectedFile = document.getElementById("txtFile").files[0];                
                var xhr = new XMLHttpRequest();
                var fd = new FormData();
                var url = '@Url.Content("~/")' + "ESignature/getFile";

                fd.append("file", document.getElementById('txtFile').files[0]);
                $("#loadingwrapper").fadeIn();
                xhr.onreadystatechange = function () { 
                    if (xhr.readyState == 4) {                       
                        var url1 = '@Url.Content("~/")' + "ESignature/Registration";
                        $('#gridAttachments').load(url1 + ' #gridAttachments');
                        $("#loadingwrapper").fadeOut();
                    }
                };
                xhr.open("POST", url, true);
                xhr.send(fd);
                $('#txtDescription').val('');
                $('#txtFile').val('');

                return false;
            } 
        });
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900