From c246d59ec18d9b429af6d7eb813b2bd92ac8caec Mon Sep 17 00:00:00 2001 From: messerbill Date: Tue, 11 Mar 2014 02:25:12 +0100 Subject: [PATCH] feedback now works - there was an error with the JSON return. Feedback function now is set to "async: false" -> data is set into db successfully and no error is fired --- uVote/api/votes/votes.php | 2 ++ uVote/page/default_page/js/loadtexts.js | 23 ++++++++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/uVote/api/votes/votes.php b/uVote/api/votes/votes.php index da8d590..95706c9 100644 --- a/uVote/api/votes/votes.php +++ b/uVote/api/votes/votes.php @@ -212,6 +212,7 @@ class votes { } public static function write_feedback($feedback){ + $feedback = json_decode($feedback); if(!\SYSTEM\SECURITY\Security::isLoggedIn()){ throw new ERROR("You need to be logged in.");} @@ -220,6 +221,7 @@ class votes { 'INSERT INTO uvote_beta_feedback VALUES (?, ?);', array(\SYSTEM\SECURITY\Security::getUser()->id, $feedback)); + new WARNING("feedback was added"); return JsonResult::ok(); } diff --git a/uVote/page/default_page/js/loadtexts.js b/uVote/page/default_page/js/loadtexts.js index 281d082..fb4b49e 100644 --- a/uVote/page/default_page/js/loadtexts.js +++ b/uVote/page/default_page/js/loadtexts.js @@ -215,10 +215,9 @@ function vote_click (poll_ID, vote) { } function submit_commentrate (c_ID, val) { - $.getJSON('./api.php?call=vote&action=commentrate&c_ID=' + c_ID + '&val=' + val, function(data) { + $.getJSON('./api.php?call=vote&action=commentrate&c_ID=' + c_ID + '&val=' + val, function(data) { var items = []; - if(data.status == true){ - alert("success"); + if(data.status == true){ } else { alert(data.result.message); } @@ -264,18 +263,24 @@ function submit_add_data () { } function send_feedback (feedback) { + var val = JSON.stringify(feedback); + console.log("feedback called"); $.ajax({ url: 'http://mojotrollz.eu/web/uVote/api.php', // contentType : "application/json; charset=utf-8", data : { - call: 'vote', - action: 'feedback', - feedback: feedback + 'call': 'vote', + 'action': 'feedback', + 'feedback': val }, - dataType : 'json', - type : 'POST' , - success: function(data) { + type : 'POST', + dataType: 'json', + async: false, + success: function() { alert("success"); + }, + error: function(error){ + alert("something failed..."+error); } }); }