How to reset a form after submission (which is submitted using ajax)?


You can place this code in your AJAX response success

     .not(':button, :submit, :reset, :hidden')
  • can you explain
    – Jaisa
    Dec 28 '17 at 6:01
  • 1
    I dont think there is any explanation needed for this but still since you are asking it will get all input fields with the form ID you have mentioned it will empty its value val(''), remove attributes removeAttr('checked') and removeAttr('selected') for checkbox and dropdowns and will ignore fields such as button by .not(':button, :submit, :reset, :hidden'). Hopes this helps.
    – Priyank
    Dec 28 '17 at 6:05

You can reset it with jquery.

Use Below code


You can do this with simple javascript as well.


You can call this in ajax success method. so once your ajax call will be success it will reset the form.

  • could you please post html code of your form ? Dec 28 '17 at 6:50
  • I have overrided the core form which is present in Magento\Review\view\frontend\templates\form.phtml. you can refer from that
    – Jaisa
    Dec 28 '17 at 9:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.