Jquery loop

Hello Everybody,

Hope all r fine.

In many application we see If anyone want to create for example category of a product, I want to make it more desktop like using jQuery Ajax.

Here is my idea:)
A form with a text field for category title. and a button will be there “create and add another”. when user clicks this button a category is successfully adding to DB using $.post but after that how I can make the form appear again as many times user wants?

regards,
Rashed

In pseudo code:


if (user submits form) {
  post values using AJAX with the callback function {
    if (values are ok) {
      show message "successfully saved"
      empty fields
    } else {
      show message "failed to save. The following errors occurred: ..."
    }
  }
}

after the submission was successful and the values were ok the user is presented with the same form but empty and can start anew :slight_smile:

Thanks so how can I make the loop?

Instead of that, why don’t you just clear all the form fields upon successful submission? Way easier IMO.