POST and GET ajax jquery

POST and GET ajax jquery

Hello,

I am posting cart values in the database with ajax and would like to know if the GET function would work for update my cart. I have all the code in php working, just need to have a way to POST and then run my cartupdate.php

Would the below code be the right way of doing this please?

Thank you.

  1. <script>

  2. $("#form-items").submit(function(e) {

  3.     $.ajax({
  4.            type: "POST",
  5.            url: "resources/templates/frontend/cart.php",
  6.            data: $("#form-item").serialize(),
  7.            success: function(data)
  8.            {
  9.                alert(data);
  10.            }
  11.          });

  12.     $.get( "cartupdate.php", function( data ) {

  13.     });

  14.     e.preventDefault();
  15. });

  16. </script>