并发 AJAX 和标准表单 POST 后连接重置

发布于 2024-09-15 21:47:57 字数 1168 浏览 1 评论 0原文

场景:

  • 自己滚动的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

十级心震 2024-09-22 21:47:57

当点击发生时,你能禁用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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文