0
  • Ajax Funcion

    add_action('wp_ajax_data_fetch_alco' , 'data_fetch_alco');
    add_action('wp_ajax_nopriv_data_fetch_alco','data_fetch_alco');
    function data_fetch_alco(){
     $object = $_POST["objectid"];
     require get_stylesheet_directory() .'/aws/aws-autoloader.php';
      define('AWS_KEY', 'XXXXXX');
      define('AWS_SECRET_KEY', 'XXXXXXXXXXXX');
      //define('HOST', 'http://103.2134.97.118/');
      //define('REGION', 'ap-south-1');
      $credentials = new Aws\Credentials\Credentials(AWS_KEY, AWS_SECRET_KEY);
      $s3 = new Aws\S3\S3Client([
          'version'     => 'latest',
          'region'      => REGION,
          'credentials' => $credentials
      ]);
      $result = $s3->listBuckets();
      //$object = 'AutoPlotter/AutoPlotter.zip';
      $secret_plans_cmd = $s3->getCommand('GetObject', ['Bucket' => 'infycons-software', 'Key' => $object]);
      $request = $s3->createPresignedRequest($secret_plans_cmd, '+2 minute');
      echo $request->getUri();
      die();
    }

  • Ajax Request

    add_action( 'wp_footer', 'ajax_fetch_posts' );
    function ajax_fetch_posts() {
    ?>
    <script>
    jQuery('.tab_download-evaluation .bt_bb_image').on('click', function() {
        jQuery('.download_evl .bt_bb_link').addClass('disabled');
        objectid = jQuery(this).attr('id');
        jQuery.ajax({
            url: '<?php echo admin_url('admin-ajax.php'); ?>',
            type: 'post',
            data: { 
             action: 'data_fetch_alco', 
             objectid: objectid,
            },
            success: function(data) {
              jQuery('.download_evl .bt_bb_link').attr('href', data);
              jQuery('.download_evl .bt_bb_link').removeClass('disabled');
            },
            error: function() {
                console.log("Error");
       }
        });
    });
    </script>
    <?php
    }

Jagdish Sarma Asked question November 19, 2021
Add a Comment