Execute without clicking, can anyone help? [closed]

1

Is this just running updating the site, it would only be used when you click on the link, could someone help me?

<a id="acceptButton" class="btn btn-success btn-block" data-value="<?php echo utf8_encode($array['folio_number']); ?>">Aceptar <i class="fa fa-check"></i></a>


<script type="text/javascript">

      $(document).ready(function() {

        $(document).on("click", ".btn-success", function(e) {

          e.preventDefault();

          var value_id = $(this).data('value');

           jQuery.ajax({
                  type: "POST",
                  data:  { input_value : value_id },
                  success: function(data,status,xhr) {
                      // Check the output of ajax call on firebug console
                      console.log(data);
                      <?php
                           $update = $datasource->acceptNewCustomer($user_id,1,utf8_decode($_POST['input_value']));
                           if ($update == 'OK') {                        
                      ?>
                            alert('Cliente agregado correctamente');
                            location.reload();
                      <?php
                          }
                          else {
                      ?>
                            alert('Error al agregar cliente');
                      <?php
                          }
                      ?>  
                  },
                  error: function () {
                      alert("error");
                  }
              }); 

        });

</script>
    
asked by anonymous 28.10.2017 / 04:55

0 answers