Skip to content
Advertisement

Foreach Condition with Ajax form submit button

I was trying to do for each condition for form but for some reason, it is submitting all foreach data with ajax.

JavaScript

For some reason the response is

JavaScript

i want to send only one option data to the cart. But, its adding all foreach data to cart

Please help, Thanks

Advertisement

Answer

JavaScript

This will serialize all forms mounted on the webpage. Instead you should serialize the submitted form only, just as you did for the submit event handler.

JavaScript

or shorthand

JavaScript

will serialize only particular form instead of all forms.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement