Einzelnen Beitrag anzeigen
  #11 (permalink)  
Alt 21.05.2020, 00:25
Iago2 Iago2 ist offline
Benutzer
neuer user
Thread-Ersteller
 
Registriert seit: 13.09.2005
Beiträge: 83
Iago2 befindet sich auf einem aufstrebenden Ast
Standard

Zitat:
Zitat von protonenbeschleuniger Beitrag anzeigen
Ajax?
Bis jetzt ging es um Serverseigien Code. Die Frage bisher was, ob das im Browser ankommt das ist was du erwartest. Wenn es beim normalen Aufruf funktioniert, dann liegt es wohl am Ajax Code, den kennen wir aber nicht.
Im Browser kommt sogar mehr an als ich erwarte. So gibt mir console.log den ganzen Inhalt der Datei an.

AJAX request ist auskommentiert.

Code:
$("#JSON-export-full").on("click", function () {
  var url = window.location.href;
  window.location.href = url + "?action=download&variation=full";

  /*  $.ajax({
    type: "POST",
    url: "actions.php?action=createFullJson",
    data: "variation=full",
    success: function (result) {
      console.log(result);
    },
  }); */
});
actions.php (für AJAX request):
Code:
if($_GET['action'] == "createFullJson") {

        $file = createFile(createAJAX($connection,$_POST['variation']));
       // echo $file." is created";

        downloadFile($file);
    }

index.php (reload der Seite):
Code:
if($_GET['action'] == "download") {

  $file = createFile(createAJAX($connection,$_GET['variation']));
      //  echo $file." is created";

        downloadFile($file);
}
Ich hab das echo $file." is created"; in index.php und action.php auskommentiert. Seltsam, dass das bei index.php einfach mit in die Datei reingeschrieben wird.

Geändert von Iago2 (21.05.2020 um 00:32 Uhr)
Mit Zitat antworten
Sponsored Links