lesquishy
lesquishy

Reputation: 137

Ajax not loading the url file

Whenever the Ajax runs, it says everything works well but as far as I can tell It's not loading the PHP file.

The console has no errors or warning.

Ajax is running the success command

Demo

PHP file (download.php)

  <script>console.log("Hello?")</script>
  <?php
    if(isset($_POST['files']) ){
      echo $_POST['files'];
    }

  ?>

JS

function downloads(){
  files = tickboxes();
  if( isset(files) ){
    $.ajax({
      data: "files=" + files,
      type: "POST",
      url: "./assets/php/download.php",
      success: function(response) {
        console.log("Download Passed Successfully");
      }
    });
  } else {
    alert("Download", "No Files Selected", "red");
  }
}

HTML

<a onclick="downloads()" id="delete" class='btn btn-default'><image src='./assets/images/download.svg'></image> Download</a>

Upvotes: 0

Views: 236

Answers (1)

Quentin
Quentin

Reputation: 943216

It is successfully loading the PHP file. Having done that, it calls the success function (which you have established runs) and populates the first argument (which you named response) with the document.

The only issue with that is that you never do anything with the value of response. Whatever the content of the document is, you're ignoring it.

Upvotes: 1

Related Questions