How To Submit 3 Forms With One Submit Button Using Ajax
Solution 1:
jQuery has a nice function for that.(.post)
https://api.jquery.com/jQuery.post/
Use .val to read form data
Solution 2:
What I would suggest is some reorganization of your code - rather than trying to post to three separate pages from 1, perhaps try either combining the steps into one, or definitively separating them into 3.
For example:
(Separating into 3):
Page one, you fill out basic information of the product, which gets submitted and inserted into the database, then you are brought to page/step 2 (via hidden POST'd fields containing specific "product ID" or something), where you choose a category from the database. When you submit from there, it is inserted into the database, and you are brought to page/step 3, where you upload an image. After submitting this, you're done!
-Advantages: Smaller individual pages, easier to make adjustments to any one of them.
-Disadvantages: Difficult to change something that affects all 3 pages, and if the user has slow internet, can lead to it taking a long time to create a single product.
(Combining):
All information is entered on a single page - category selection, basic product info, and file upload. Submitting that page will process ALL the information in one fell swoop.
-Advantages: Easier to make large changes, all info is loaded/submitted at once so you won't end up with partial of incomplete data in your databases.
-Disadvantages: Lots of information to fill out on one page, may make finding a single thing to change difficult with a large amount of code.
Post a Comment for "How To Submit 3 Forms With One Submit Button Using Ajax"