I need to update the user's points on each drop he successfully make, but for some reason the $.ajax call seems to not work as desired... I am getting the current points using $('#userPoints').val(), then I would like to make each and addition to the current number or set first score - if...else. Any help?
function Point() {
var phpPoints = $('#userPoints').val();
if (phpPoints != null) {
var Usrpoints = phpPoints + 5;
} else {
var Usrpoints = 5;
}
alert('Points: '+phpPoints);
var sndData = { acts:'Points', points: Usrpoints };
$.ajax({ // begin add ajax
type: "POST",
url: "game/lib/updateGame.php",
dataType:"html",
cache: false,
data: sndData,
success: function(sndData) {
$('div#UpdateUser').html(sndData).fadeIn('slow');
}
}); // end ajax
}
here instead of td use the element in which you are droping
$('td').bind('dropstop', function(){ Point(); });
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.