Failed to send new action method via .Ajax immediately after successful XMLHttpRequest in IE 10

I am adding a new feature in my application that allows users to complete the process step by step.

Step1 select the dropdown value

click the next button and step 2 (the ajax request loads and displays a partial view, displaying a tree view)

press the next button

step 3 (upload file via XMLHttpRequest)

press the next button

Step 4 (another ajax request is executed for partial viewing) For some reason, this request will never hit the controller action method. Which is strange, if I send the action to the method in step 2, it will be published successfully, but I have a different action for this action.

I get the following warnings in IE 10 developer tools

SEC7127: Redirect was blocked for CORS request.

XMLHttpRequest: network error 0x800c0014, redirection problem occurred. SCRIPT7002: XMLHttpRequest: network error 0x800c0014, A redirect problem.

The above errors seem to be related to XMLhhtprequest before this step. I tried to set XMLhttprequest to NULL or try to delete it on its successful event. I do not understand in step 4, can I still send the action of step 2, but not another?

step 3

function handleFiles() { var formdata = new FormData(); //FormData object var xhr = new XMLHttpRequest(); xhr.open('POST', fileUploadURL); xhr.setRequestHeader('Content-type', 'multipart/form-data'); //Appending file information in Http headers xhr.setRequestHeader('X-File-Name', document.getElementById('myFile').files[0].name); xhr.setRequestHeader('X-File-Type', document.getElementById('myFile').files[0].type); xhr.setRequestHeader('X-File-Size', document.getElementById('myFile').files[0].size); //Sending file in XMLHttpRequest xhr.send(document.getElementById('myFile').files[0]); xhr.onreadystatechange = function () { if (xhr.readyState == 4 && xhr.status == 200) { $("input[id=filestoredname]").val(xhr.responseText); alert("file saved.."); } } return false; } var instrumentSelectionUrl = '@Url.Action("Step2", "ErrorCode")';//step2 var finalTreeViewUrl = '@Url.Action("renderFinalTree", "ErrorCode")';//step3 var fileUploadURL = '@Url.Action("UploadFiles", "ErrorCode")';//step3 $(function () { $('form').stepy({ backLabel: '<<', nextLabel: '>>', finishButton: false, next: function (index) { alert(index); var v = $("#InsIdLst").chosen().val(); if (v == null && index == 2) { alert("Please select an Instrument"); return false; } if (v != null && index == 2) { var overlay = $('<div></div>').prependTo('body').attr('id', 'overlay'); $.ajax({ type: 'POST', url: instrumentSelectionUrl, cache: false, datatype: "html", data: $("form").serialize(), success: function (result) { $("#errorCodes").html(result); overlay.remove(); } }); } if (index == 4) { alert("try.."); $.ajax({ type: 'POST', url: finalTreeViewUrl, cache: false, datatype: "html", data: $("form").serialize(), success: function (result) { $("#errorCodesSave").html(result); } }); } } }); }); 
+7
jquery ajax asp.net-mvc-3
source share
1 answer

So, in step 4, if I use

 $("#errorCodesSave").load(finalTreeViewUrl, { fileName: $("#filestoredname").val(), $("#InsIdLst").chosen().val();: 1 }); 

instead of $ Ajax, it does the job of the controller. This works for me quite well.

+3
source

All Articles