diff --git a/Backend/Controllers/FileHandler/GetGameData.php b/Backend/Controllers/FileHandler/GetGameData.php index 90c00bd..01445c6 100644 --- a/Backend/Controllers/FileHandler/GetGameData.php +++ b/Backend/Controllers/FileHandler/GetGameData.php @@ -14,6 +14,7 @@ if(isset($_GET['gameDataId'])){ $openGameDataStream = GameData::all(); } - +header("Access-Control-Allow-Methods: GET"); +header("Access-Control-Allow-Headers: X-Requested-With, Content-Type, Accept"); header('Content-Type: application/json;charset=UTF-8'); echo $openGameDataStream->toJson(JSON_PRETTY_PRINT); \ No newline at end of file diff --git a/Backend/Controllers/GameJam/GetGameJam.php b/Backend/Controllers/GameJam/GetGameJam.php index 5e1e345..1dd4d1b 100644 --- a/Backend/Controllers/GameJam/GetGameJam.php +++ b/Backend/Controllers/GameJam/GetGameJam.php @@ -9,8 +9,9 @@ if(isset($_GET['gameJamId'])){ $dbValue = GameJam::all(); } -header("Access-Control-Allow-Origin: *"); header("Access-Control-Allow-Methods: GET"); -header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept"); +header("Access-Control-Allow-Headers: X-Requested-With, Content-Type, Accept"); header('Content-Type: application/json;charset=UTF-8'); -echo $dbValue->toJson(JSON_PRETTY_PRINT); \ No newline at end of file +echo $dbValue->toJson(JSON_PRETTY_PRINT); + +//var_dump(headers_list()); \ No newline at end of file diff --git a/Backend/Controllers/Group/GetGroup.php b/Backend/Controllers/Group/GetGroup.php index 9a961a1..dad8464 100644 --- a/Backend/Controllers/Group/GetGroup.php +++ b/Backend/Controllers/Group/GetGroup.php @@ -12,5 +12,7 @@ else{ $groups = Group::all(); } +header("Access-Control-Allow-Methods: GET"); +header("Access-Control-Allow-Headers: X-Requested-With, Content-Type, Accept"); header('Content-Type: application/json;charset=UTF-8'); echo $groups->toJson(JSON_PRETTY_PRINT); \ No newline at end of file diff --git a/Backend/Controllers/Polls/GetWinner.php b/Backend/Controllers/Polls/GetWinner.php index bb535f0..a81710d 100644 --- a/Backend/Controllers/Polls/GetWinner.php +++ b/Backend/Controllers/Polls/GetWinner.php @@ -21,6 +21,9 @@ if(isAdmin() && isset($_GET['gameJamId'])){ $winningGroups->push($group); } } + + header("Access-Control-Allow-Methods: GET"); + header("Access-Control-Allow-Headers: X-Requested-With, Content-Type, Accept"); header('Content-Type: application/json;charset=UTF-8'); echo $winningGroups->toJson(JSON_PRETTY_PRINT); diff --git a/Backend/Controllers/keyWord/GetKeyWinner.php b/Backend/Controllers/keyWord/GetKeyWinner.php index 3628bee..1000131 100644 --- a/Backend/Controllers/keyWord/GetKeyWinner.php +++ b/Backend/Controllers/keyWord/GetKeyWinner.php @@ -8,14 +8,16 @@ use \Backend\Models\GameJam; use \Illuminate\Support\Collection; if (!isAdmin()){ - if(isset($_POST['genKeyWord'])){ - $gameJamId = $_POST['gameJamId']; + if(isset($_GET['genKeyWord'])){ + $gameJamId = $_GET['gameJamId']; $game_jam = GameJam::find($gameJamId); $all_group_in_game_jam_id = Group::where("game_jam_id", $game_jam->id)->pluck("id")->toArray(); $find_all_keywords = KeyWord::whereIn("group_id", $all_group_in_game_jam_id)->inRandomOrder()->get(); $game_jam->key_word = $find_all_keywords->first()->key_word; $game_jam->save(); + header("Access-Control-Allow-Methods: GET"); + header("Access-Control-Allow-Headers: X-Requested-With, Content-Type, Accept"); header('Content-Type: application/json;charset=UTF-8'); echo $find_all_keywords->pluck("key_word")->toJson(JSON_PRETTY_PRINT); } diff --git a/Backend/Main.php b/Backend/Main.php index 825a77a..9e8ec94 100644 --- a/Backend/Main.php +++ b/Backend/Main.php @@ -33,6 +33,21 @@ $gameJam = GameJam::firstOrCreate([ + $value) { + echo "$name: $value
"; +} + +echo "
"; + +var_dump(headers_list()); + +?> + diff --git a/Frontend/Javascript/qweData.js b/Frontend/Javascript/qweData.js index c3b2c9a..2770f4c 100644 --- a/Frontend/Javascript/qweData.js +++ b/Frontend/Javascript/qweData.js @@ -6,10 +6,14 @@ $(window).on("load", function(){ function dataFetch(){ $.ajax({ type: "GET", - url: "/Game-Jaming/Backend/Controllers/FileHandler/GetGameData.php?gameJamId=1", + url: "/Game-Jaming/Backend/controllers/GameJam/GetGameJam.php", success: function(result){ - console.log(result); - console.log(result[0].game_link) + console.log(result[0].name); } }); -} \ No newline at end of file +} + + + +//console.log(result.name); ?gameJamId=1 +//console.log(result[0].name); uden ?gameJamId=1 \ No newline at end of file