3

Somehow ajaxSubmit and ajaxForm kinda play the same role. If so, then, Is there any significant difference between them ? If so; which to use, when and why?

ErickBest
  • 4,586
  • 5
  • 31
  • 43
  • possible duplicate of [jQuery AJAX submit form](http://stackoverflow.com/questions/1960240/jquery-ajax-submit-form) – Ohgodwhy Jul 21 '13 at 15:31
  • I dont think the possible Dup answers this questions: * is it possible to get the progress value like done in ajaxForm? i.e: `uploadProgress: function(event, position, total, percentComplete)`* – ErickBest Jul 21 '13 at 15:46
  • Then that should be your question, not, "what is the significant difference", which is covered in the question that I reported as being a duplicate. – Ohgodwhy Jul 21 '13 at 15:47
  • Then that might be one of the differences am looking for... using this question, we could get more of such differences than the possible Dup which asked less of the difference(s) between the two. – ErickBest Jul 21 '13 at 15:52
  • Actually, it is generally advisable not to be so ambiguous when requesting information. If you specifically need access to `uploadProgress` then that is what your question is about. If there is something else, create a new question about that particular feature. In this format, it's not really a good fit for what we're trying to achieve. Moreover, Questions should demonstrate a minimal understanding of the objective trying to be achieved, and should include code indicating what you've tried, and why it failed. – Ohgodwhy Jul 21 '13 at 16:35

1 Answers1

12

The 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).

So, ajaxSubmit actually submits the form to its destination while ajaxForm preps everything and waits for the form to be submitted.

Your could run ajaxSubmit in place of $("#formID").submit()


UPDATE

In response to the comment below about uploadProgress the Options page on the same site says:

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.

There is nothing on uploadProgress being excluded from either so I would say uploadProgress is available in both. How that's used is a different question altogether ;-)

Jason
  • 15,017
  • 23
  • 85
  • 116
  • but is it possible to get the progress value like done in ajaxForm? i.e: `uploadProgress: function(event, position, total, percentComplete)`.. can this be done in ajaxSubmit? – ErickBest Jul 21 '13 at 15:39