gpt4 book ai didi

javascript - jQuery:ajaxSubmit/ajaxForm 有什么显着区别吗?

转载 作者:搜寻专家 更新时间:2023-10-31 22:01:00 25 4
gpt4 key购买 nike

不知何故 ajaxSubmit 和 ajaxForm 起到了同样的作用。如果是这样,那么它们之间有什么显着差异吗?如果是这样;使用哪个,何时以及为什么?

最佳答案

FAQ reads :

What is the difference between ajaxForm and ajaxSubmit?

There are two main differences between these methods:

  • ajaxSubmit submits the form, ajaxForm does not. When you invoke ajaxSubmit it immediately serializes the form data and sends it to the server. When you invoke ajaxForm it adds the necessary event listeners to the form so that it can detect when the form is submitted by the user. When this occurs ajaxSubmit is called for you.
  • When using ajaxForm the submitted data will include the name and value of the submitting element (or its click coordinates if the submitting element is an image).

因此,ajaxSubmit 实际上是将表单提交到目的地,而 ajaxForm 准备好所有内容并等待表单提交。

您可以运行 ajaxSubmit 代替 $("#formID").submit()


更新

回应下面关于uploadProgress 的评论 Options page在同一网站上说:

Note: Aside from the options listed below, you can also pass any of the standard $.ajax options to ajaxForm and ajaxSubmit.

Both ajaxForm and ajaxSubmit support numerous options which can be provided using an Options Object.

uploadProgress 没有任何内容被排除在外,所以我会说 uploadProgress 在两者中都可用。如何使用它完全是一个不同的问题;-)

关于javascript - jQuery:ajaxSubmit/ajaxForm 有什么显着区别吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17773914/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com