并发 AJAX 和标准表单 POST 后连接重置
场景:
- 自己滚动的 jQuery Ajax 帖子用于验证未焦点上的输入字段
- 用于表单上帖子的标准提交按钮
如果我导致验证触发并等到我在 firebug 中看到它完成,然后单击“保存全部”就可以了。但是,如果我在字段中进行更改,然后直接单击提交按钮(因此 ajax 和标准发布几乎同时发生),则请求会在返回“连接重置”之前挂在浏览器中。如果在 VS 调试中运行,除非按下暂停键,否则我什么也看不到。然后我看到以下调用堆栈:
System.Web.dll!System.Web.Hosting.IIS7WorkerRequest.ReadEntityCoreSync(byte[] buffer, int offset, int size) + 0x23 bytes
System.Web.dll!System.Web.Hosting.IIS7WorkerRequest.ReadEntityBody(byte[] 缓冲区, int 大小) + 0x18 字节
System.Web.dll!System.Web.HttpRequest.GetEntireRawContent() + 0x2d4 字节
System.Web.dll!System.Web.HttpRequest.GetMultipartContent() + 0x45 字节
System.Web.dll!System.Web.HttpRequest.FillInFormCollection() + 0xad 字节
System.Web.dll!System.Web.HttpRequest.Form.get() + 0x45 字节
System.Web.dll!System.Web.HttpRequest.HasForm.get() + 0x46 字节
System.Web.dll!System.Web.UI.Page.GetCollectionBasedOnMethod(bool dontReturnNull) + 0x62 bytes
背景:
ASP.NET 4 MVC 2 Web 应用程序,带有一些旧版 Webforms 页面(ajax post 中涉及的页面)标准帖子是在 Win7/IIS7 上本地运行的相同 Web 表单页面。
我可能会在 ajax 验证触发时禁用提交按钮。然而,即使我这样做,我也很想知道是什么导致了这个看似基于时间/并发请求的问题。
Scenario:
- Own rolled jQuery Ajax post to validate an input field on unfocus
- Standard submit button for post on form
If I cause validation to fire and wait until I see it complete in firebug then click save all is fine. If however I leave a change in a field and then click the submit button directly (so both ajax and standard post happen at almost the same time) the request hangs in the browser before returning a 'connection reset'. If running in VS debug I see nothing unless I hit pause. I am then presented with the following callstack:
System.Web.dll!System.Web.Hosting.IIS7WorkerRequest.ReadEntityCoreSync(byte[] buffer, int offset, int size) + 0x23 bytes
System.Web.dll!System.Web.Hosting.IIS7WorkerRequest.ReadEntityBody(byte[] buffer, int size) + 0x18 bytes
System.Web.dll!System.Web.HttpRequest.GetEntireRawContent() + 0x2d4 bytes
System.Web.dll!System.Web.HttpRequest.GetMultipartContent() + 0x45 bytes
System.Web.dll!System.Web.HttpRequest.FillInFormCollection() + 0xad bytes
System.Web.dll!System.Web.HttpRequest.Form.get() + 0x45 bytes
System.Web.dll!System.Web.HttpRequest.HasForm.get() + 0x46 bytes
System.Web.dll!System.Web.UI.Page.GetCollectionBasedOnMethod(bool dontReturnNull) + 0x62 bytes
Background:
ASP.NET 4 MVC 2 Web application with some legacy webforms pages (the page involved in both the ajax post and standard post is the same webforms page) running locally on Win7/IIS7.
I could potentially disable the submit button while the ajax validation fires. However even if I do that I'm intrigued to know what has caused this seemingly time based/concurrent request problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当点击发生时,你能禁用ajax post吗?
这样,您必须在执行其他操作之前检查点击事件中的条件。
Can you disable the ajax post, when clicking happens?
this way you have to check for the conditions in the click event, before you do anything else.