diff --git a/bin/settings.js b/bin/settings.js index 4dbf2bc..0b4768c 100644 --- a/bin/settings.js +++ b/bin/settings.js @@ -12,7 +12,12 @@ $(document).ready(function(){ $("#mail-input").focus(function(){$(this).css("color", "black");}); $("#export-recipe-button").click(function(){ $.post("/php/edit-recipes.php", {function:"export"}, function(data){ - downloadObjectAsJson(data, "recipes"); + downloadObjectAsJson(JSON.parse(data), "recipes"); + }); + }); + $("#export-list-button").click(function(){ + $.post("/php/edit-list.php", {function:"export"}, function(data){ + downloadObjectAsJson(JSON.parse(data), "list"); }); }); }); diff --git a/php/edit-list.php b/php/edit-list.php index e9237df..ede9866 100644 --- a/php/edit-list.php +++ b/php/edit-list.php @@ -19,6 +19,11 @@ case 'check': $shopping->check($_POST["id"], $_POST["status"]); + break; + + case 'export': + echo json_encode($shopping); + break; default: // code... diff --git a/php/edit-recipes.php b/php/edit-recipes.php index 5d7040e..857bda4 100644 --- a/php/edit-recipes.php +++ b/php/edit-recipes.php @@ -29,7 +29,6 @@ case 'export': $book->fillCookbook(); - header("Content-type: text/json"); echo json_encode($book); break;