我正在使用jquery向可能需要一段时间返回的控制器方法发出ajax请求。我遇到的问题是,我无法重新加载页面,直到ajax请求完成..它只是挂起,直到控制器方法完成,然后重新加载页面。长时间运行ajax请求,防止页面重新加载
这是我的ajax请求。
$.ajax({ async:true, type: "POST", url: url, data: senddata, dataType: "xml", success: GetLayerFeaturesCallback });
我正在使用一个AsyncController并等待10秒钟返回。
public void GetFeaturesAsync(int layerId, BoundingBox bbox, int maxFeatures = 50)
{
AsyncManager.OutstandingOperations.Increment();
Task task = Task.Factory.StartNew(() => {
System.Threading.Thread.Sleep(10000);
});
task.ContinueWith(t => {
AsyncManager.Parameters["element"] = new XElement("TEST");
AsyncManager.OutstandingOperations.Decrement();
});
}
public XmlActionResult GetFeaturesCompleted(XElement element)
{
return new XmlActionResult(element);
}
为什么我不能重新加载页面,直到该方法完成?
2011-08-03
mdm20