我有jQuery的AJAX调用这对于总结计数请求WEB API服务。 的WEB API处理请求并调用传递请求参数的存储过程(SQL服务器)。 该存储过程需要较长的时间(超过10分钟来处理请求。如果存储过程需要超过10分钟的jQuery的AJAX调用报告的状态代码:12002或12152未知错误(这些错误涉及到连接问题),但Web服务器在10分钟后收到的结果从存储过程了。问题是在浏览器中存在的是IE8.0,IE9.0,火狐但Chrome是接收,即使它等待超过10分钟响应。是否有任何解决方案,以保持在服务器和客户端之间活着的沟通。我试图从阿贾克斯改变连接请求标题为“关闭”,“开放”,“保持活动”没有什么作品。请帮助我。
Java脚本代码。
$.ajax({
type: "post",
url: URLPrefix + 'api/querydispatcher/summary',
data: s,
success: function (data) {
window.clearInterval(int);
$('#wait').hide();
$('#CancelSummary').hide();
$('#backgroundmodal').hide();
$("#tResultTotals").slideDown('slow');
DeserializeJSon(eval(data));
if (!CancelSummaryRequest) {
CancelSummaryRequest = true;
$('#DownloadDetailedReport').show();
}
else {
$('#tResultTotals').hide();
}
},
$('#wait').hide();
$('#CancelSummary').hide();
$('#backgroundmodal').hide();
error_Dialog(request.responseText);
}
});
}
Server Side (WEB API) code.
[WebInvoke(UriTemplate = "summary", Method = "POST")]
public List<QueryResult> GetSummaryReport_Queue(JsonValue SummaryXML)
{
MyContext db = new MyContext();
DateTime StartTime = DateTime.Now;
string sumXML = SummaryXML["XMLJson"].ToString().Replace(@"\", "").Replace(@"""", "");
//These are two codes created by JSon @ the end of the String that need to be trim off.
sumXML = sumXML.Replace("u000du000a", "");
List<QueryResult> results = null;
XElement xxml = XElement.Parse(sumXML);
string ReportID = xxml.Descendants("ReportId").FirstOrDefault().Value;
string err = "";
try
{
results = db.fnReportResult(sumXML).ToList();
}
catch (Exception e)
{
err = e.Message + " : "+(e.InnerException!=null?e.InnerException.Message : "");
throw e;
}
finally {
///--- Record Audit Info.
double RunningTime = DateTime.Now.Subtract(StartTime).TotalMilliseconds;
string parameters = "ApplicationType:Query_Dispatcher" + "||User:" + SummaryXML["UserId"].ToString().Replace(@"\", "").Replace(@"""", "") +
"||Session:" + SummaryXML["Session"].ToString().Replace(@"\", "").Replace(@"""", "") +
"||Running Time:" + RunningTime.ToString() + "||Request Type:Summary Report" +
"||Report ID:" + ReportID +
"||Error:" + err;
Audit SaveAudit = new Audit();
SaveAudit.WriteAudit("Query_Builder", parameters);
//####-Recording Audit Info
}
return results;
}