From 31dbbf01e3f72ac64ba7635a9a31d7b6879deb6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kasper=20Rynning-T=C3=B8nnesen?= Date: Fri, 8 Aug 2014 18:25:55 +0200 Subject: [PATCH] g --- index.php | 18 ++++++++++++++++-- save.php | 2 ++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/index.php b/index.php index 76b00300..d90d0953 100644 --- a/index.php +++ b/index.php @@ -70,7 +70,7 @@ if(isset($_GET['v'])){ function onytplayerStateChange(newState) { if(newState == 0) { - $.ajax({ + /*$.ajax({ type: "POST", url: "save.php", data: "thisUrl="+response, @@ -79,7 +79,21 @@ if(isset($_GET['v'])){ console.log("saved"); console.log(response); } - }); + });*/ + + $.ajax({ + type : 'post', + //dataType : '', // http://en.wikipedia.org/wiki/JSON + url : 'save.php', + data : "thisUrl="+response, + success: function(ans) { + if( ans.type == 'success' ) { + alert('Bravo! ' + ans.result); + } else { + alert('Error!'); + }; + } + }); setTimeout(function(){ response = $.ajax({ type: "GET", diff --git a/save.php b/save.php index ca715755..ae9b9502 100644 --- a/save.php +++ b/save.php @@ -20,9 +20,11 @@ array_shift($data); } file_put_contents("videos.json", json_encode($data)); + echo $data; unset($data); }else { echo "You're a bad boy"; } + die(); ?> \ No newline at end of file