Ajax jQuery api /cart/add.js isnt working

1 0 0

okay so check this out, this is a script for a button I wrote. It is supposed to add the product "priority processing" to the card if you press it, without reloading the page and notification. you can also go to https://pillow-squish.com/404 and check it out.



{% comment %} BUTTONTEST {% endcomment %}

  <button id="priority-processing-button">Add Priority Processing</button>

    $(document).ready(function() {
      $("#priority-processing-button").click(function() {
          url: "/cart/add.js",
          type: "POST",
          dataType: "json",
          data: {
            quantity: 1,
            id: 8160342704429,
            properties: {
              "title": "Priority Processing"
          success: function() {
            alert("Priority Processing added to cart!");
          error: function(XMLHttpRequest, textStatus, errorThrown) {
            console.error("Error: " + errorThrown);



 I also inserted AJAX into the theme.liquid with this code:


{% comment %} add jQuery {% endcomment %}
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script> 


it gives me a 404 error in the console. im not to good at coding to be honest since im just starting out. I desperately hope somebody can help me i've been stuck on this for 2 days now...


The product id is definetly 100% right i believe. I went on the product page in the admin pannel and copied the ID from the URL.

Replies 0 (0)