test
This commit is contained in:
@@ -79,7 +79,7 @@ $(function() {
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify(dataToSave),
|
||||
success: function(response) {
|
||||
console.log(response);
|
||||
console.info(response);
|
||||
},
|
||||
error: function(error) {
|
||||
console.error(error);
|
||||
@@ -87,7 +87,20 @@ $(function() {
|
||||
});
|
||||
}
|
||||
|
||||
var savedValue = localStorage.getItem("sliderValue");
|
||||
//var savedValue = localStorage.getItem("sliderValue");
|
||||
// overwrite savedValue with value from server
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "saveData.php", // Název skriptu na serveru
|
||||
success: function(response) {
|
||||
savedValue = response.sliderValue;
|
||||
// Zde můžete provést další akce s načtenou hodnotou
|
||||
console.info("Načtená hodnota:", savedValue);
|
||||
},
|
||||
error: function(error) {
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
if (savedValue) {
|
||||
slider.slider("value", parseInt(savedValue));
|
||||
$("#text_ad").text(getText(savedValue));
|
||||
|
||||
@@ -3,9 +3,23 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$data = json_decode(file_get_contents('php://input'), true);
|
||||
|
||||
// Uložte hodnotu obličeje (a další data) na serveru
|
||||
file_put_contents('data.json', json_encode($data));
|
||||
file_put_contents('adf/data.json', json_encode($data));
|
||||
|
||||
echo json_encode(['success' => true]);
|
||||
} elseif ($_SERVER['REQUEST_METHOD'] === 'GET') {
|
||||
// Kontrola existence souboru
|
||||
$filePath = 'adf/data.json';
|
||||
if (file_exists($filePath)) {
|
||||
// Načtení obsahu souboru
|
||||
$fileContent = file_get_contents($filePath);
|
||||
|
||||
// Odeslání obsahu zpět klientovi
|
||||
header('Content-Type: application/json');
|
||||
header('Access-Control-Allow-Origin: *'); // Povolení Cross-Origin požadavků
|
||||
echo $fileContent;
|
||||
} else {
|
||||
echo json_encode(['error' => 'File not found']);
|
||||
}
|
||||
} else {
|
||||
echo json_encode(['error' => 'Invalid request method']);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user