Zitat:
Zitat von protonenbeschleuniger
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.