I got the following insistent JS issue just for IE 8-9, in other browsers my code working very well.
Case: I have the following code in JS, which should start some server process and update progress bar with status on server side, what Jquery UI provide:
$("#btnSendUser").click(function (event) {
$.ajax({
type: "POST",
url: "/StartLongProcess",
dataType: "json",
traditional: true,
data: { userIds: users },
success: function (result) {
console.log("Process start");
}
});
var processId = 0;
getStatus(processId);
});
function getStatus(processId) {
var url = '/GetStatus';
$.get(url, { clientProcessId: processId }, function (data) {
if (!data.IsDone) {
$("#progress").progressbar({ value: data.Progress });
window.setTimeout("getStatus(" + processId + ")", 350);
}
else {
$("#progress").progressbar({ value: 100 });
console.log("Done");
};
});
}
In StartLongProcess method in current controller I starting long server process in this way: ..
[ValidateInput(false)]
public void StartLongProcess(Guid[] userIds)
{
...
var processTask = new LongProcess(MesssageService.Email.SendMails);
processTask.BeginInvoke(service.LongProcess(userIds), new AsyncCallback(EndSendingProcess), processTask);
}
Method that read current status is next:
/// <summary>
/// Gets the current progress.
/// </summary>
/// <param name="id">The id.</param>
public JsonResult GetCurrentProgress(int clientProcessId)
{
ControllerContext.HttpContext.Response.AddHeader("cache-control", "no-cache");
var currentProgress = MesssageService.Email.GetCurrentLog(clientProcessId);
return Json(currentProgress ?? new LogMessage(0), JsonRequestBehavior.AllowGet);
}
I tested this code in Chrome and FF, in those browsers progress bar and process finished correctly always. But in IE 8-9 it looks like getStatus function can't be called in this way. Is it true? What is the best way to implement my task for all browsers? Thanks.
IE8 doesn't provide 'console.log()' as enviroment function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With