Why isn't my AJAX post request posting to the updated URL?

I have an input button

<input type="button" class="ariPartListAddToCart ariImageOverride" id="ariparts_btnCart0" onclick="ARI.PartStream.Cart.PostSkuQty(this.id, 'POST', 'PartsDetail', '', '')" value="Add To Cart" name="c.myshopify.com/cart?arisku=dd-HR0-F01AH&ariqty={aripartqty}&ariprice=138.17&aribrand=HOM&arireturnurl={arireturnurl}" brand="HOM"> 

and I have this AJAX call:

  $(document).ready(function() {
            $('.ariPartListAddToCart').on('click', function() {
             var $button = $(this);
              var arisku = $button.data('arisku');
              var ariqty = $button.data('ariqty');
              var ariprice = $button.data('ariprice');
              var aribrand = $button.data('aribrand');
              var arireturnurl = $button.data('arireturnurl');
              
              // Update the name attribute value
              var updatedName = 'http://demowebsite.com/democart/cart.aspx';
              $button.attr('data-name', updatedName); // Update the data-name attribute
    
              
              // Construct data object
              var dataObj = {
                arisku: arisku,
                ariqty: ariqty,
                ariprice: ariprice,
                aribrand: aribrand,
                arireturnurl: arireturnurl,
                name: updatedName
              };
              
              $.ajax({
                type: 'POST',
                url: '/cart/add.js',
                data: dataObj,
                dataType: 'json',
                success: function() {
                  alert('This is success')
                },
                error: function() {
                  alert('Not Success')
                }
              });
            });
          });

The input button, is coming from a script that I call from our vendor server. I have used product-form.js to include the ajax above, however, whenever I click on Add To Cart button from that input button, it is still taking me to c.myshopify.com/cart instead of the url updatedName. Am I on the right track?

Hey,

I hope you are well and safe!!

Please update this code:

$(‘.ariPartListAddToCart’).on(‘click’, function(e) {
e.preventDefault();

Your code

});

Thank you

Pooja

Hello Pooja_d_92,

Thank you, I tried it and it is still the same :disappointed_face: .

Please share the website link.

Hello Pooja,

https://staging-maddparts.myshopify.com/pages/oem-parts the pw is test.

select any of the brand, until you reach an Add To Cart button. that is where I am having issues with.

Add this script file in top of tag:

Do you mean, right above the liquid head tag where I had called my custom script?

Yes

It is still the same :disappointed_face: .

I wonder if I have to do something with the cart.js? Sorry I am very new to Shopify / liquid and all its features.

Okay, can you give me the access for files and will update code.

Thank you

Sent you a private message! :slightly_smiling_face: thank you!