From 3563e6753dfd49784ec4ee7e1dce1bebe0035669 Mon Sep 17 00:00:00 2001 From: mgfcf <m.giller@tu-braunschweig.de> Date: Tue, 12 Oct 2021 16:08:01 +0200 Subject: [PATCH] Not working + modifications --- editor/js/graph.js | 10 ++++++---- knowledge-space.php | 5 +++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/editor/js/graph.js b/editor/js/graph.js index ef62c30..679857f 100644 --- a/editor/js/graph.js +++ b/editor/js/graph.js @@ -49,8 +49,8 @@ export class Graph extends ManagedData { let payload = { action: "update_space", - name: "space", - payload: data, + graph: JSON.stringify(data), + space: space_id, }; jQuery.ajax({ @@ -63,10 +63,12 @@ export class Graph extends ManagedData { // processData: false, // dataType: "json", success: function (data) { - alert(data); + console.log(data); + alert("Success"); }, error: function (errMsg) { - alert(errMsg); + console.log(errMsg); + alert("Failure"); }, }); } diff --git a/knowledge-space.php b/knowledge-space.php index bf5ca23..15004a6 100644 --- a/knowledge-space.php +++ b/knowledge-space.php @@ -91,8 +91,9 @@ function update_space() { if (current_user_can("edit_posts")) { $plugin_dir = plugin_dir_path(__FILE__); // Use json encoding. - $filename = $plugin_dir . $_POST["name"] . ".json"; - $result = file_put_contents($filename, json_encode($_POST["payload"])); + $payload = json_encode($_POST["payload"]); + $filename = $plugin_dir . $payload["space"] . ".json"; + $result = file_put_contents($filename, $payload["graph"]); //echo print_r($_POST); echo "Saved file at "; -- GitLab