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.
@cleric Can always try
rather than
. – Anthony Grist Jan 18 at 22:50