I hate to ask a more technical question here and not the discord but I’m not getting replies over there or on StackOverflow.

My problem is basically this: I’m trying to add two products to a Shopify cart on one click. When the button is clicked, the request is made, response comes back, and cart slideout is triggered. Sometimes two products show up and sometimes they don’t. It seems that my add to cart function is continuing before the 2nd response is received. I know I need to make an array for a queue and then send it over one by one to the function handling the ajax requests. I’ve seen other implementations online but I’m unsure how I can apply them.

The code

r/webdev - Inconsistent AJAX behavior

My add function, gets two pre-selected items from form. Loops over and sends to itemAdd function

r/webdev - Inconsistent AJAX behavior

Item add function top half

r/webdev - Inconsistent AJAX behavior

itemAdd function bottom half

Source link

Write A Comment