Advertisement
Guest User

Untitled

a guest
Jan 15th, 2020
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.25 KB | None | 0 0
  1. // Here's the element I'm grabbing from
  2.     <a href="#" id="clickable" date="<?php echo htmlentities(json_encode($dateArray)) ?>" customer="<?php echo htmlentities(json_encode($customerArrayClean)) ?>">
  3.         <i class="far fa-plus-square fa-2x"></i>
  4.     </a>
  5.  
  6. // Here's the AJAX call
  7.     <script>
  8.         $(document).ready(function()
  9.         {
  10.             $("#clickable").click(function (e)
  11.             {
  12.                 e.preventDefault();
  13.                 let date = $("#clickable").attr("date");
  14.                 let customer = $("#clickable").attr("customer");
  15.                 console.log(date); // OUTPUT -- ["2019-12-15","2020-01-15"]
  16.                 console.log(customer); // OUTPUT -- ["CUSTOMER 1","CUSTOMER 2","CUSTOMER 3","CUSTOMER 4"]
  17.                 $.ajax
  18.                 ({
  19.                     type: "POST",
  20.                     url: "./reconciler_process_customers_testing.php",
  21.                     data: {
  22.                         date: date,
  23.                         customer: customer
  24.                     },
  25.                     success: function(html)
  26.                     {
  27.                         if (html.success == true) {
  28.                             alert("WORKED");
  29.                         }
  30.                     },
  31.                     error: function()
  32.                     {
  33.                         alert("DIDNT WORK...YET");
  34.                     }
  35.                 });
  36.             });
  37.         });
  38.     </script>
  39.  
  40. // Here's the arrays being decoded
  41.     $dateArray = json_decode($_POST['date'], true);
  42.     $customerArray = json_decode($_POST['customer'], true);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement