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

This commit is contained in:
messerbill 2014-03-11 02:25:12 +01:00
parent a79bc90933
commit c246d59ec1
2 changed files with 16 additions and 9 deletions

View File

@ -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();
}

View File

@ -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);
}
});
}