Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在拖放JQuery PHP上更新用户点_Php_Jquery_Ajax - Fatal编程技术网

在拖放JQuery PHP上更新用户点

在拖放JQuery PHP上更新用户点,php,jquery,ajax,Php,Jquery,Ajax,我需要更新用户每次成功滴下的点数,但由于某些原因,$.ajax调用似乎无法按预期工作。。。 我使用$('#userPoints').val()获取当前分数,然后我希望将每个和添加到当前数字或设置第一个分数-如果…否则。 有什么帮助吗 功能点(){ 在这里,不要使用td,而是使用您正在拖放的元素 $('td').bind('dropstop',function(){Point(); })我不明白你的问题到底出在哪里?出于某种原因,它一直在获取上一个分数,即0,在第一次下降时,分数更新为5,但从那

我需要更新用户每次成功滴下的点数,但由于某些原因,$.ajax调用似乎无法按预期工作。。。 我使用$('#userPoints').val()获取当前分数,然后我希望将每个和添加到当前数字或设置第一个分数-如果…否则。 有什么帮助吗

功能点(){


在这里,不要使用td,而是使用您正在拖放的元素

$('td').bind('dropstop',function(){Point();
})

我不明白你的问题到底出在哪里?出于某种原因,它一直在获取上一个分数,即0,在第一次下降时,分数更新为5,但从那时起,它不会“拾取”以获取新分数…我是否遗漏了什么?你是否尝试在输入
$(“#userPoints”)中再次设置分数。val(5)
刚刚考虑过这个问题-我对JQuery还不熟悉,所以还在想办法。我会尝试一下或者用其他方法破解它…谢谢忍者让我知道如果它不起作用,另一个建议是你必须在更新函数之外定义
var Usrpoints
然后只使用
Usrpoints
对不起,我是JQuery的新手,这没有意义…wh在is$('td')?您正在将元素拖到某个div或td之类的位置
            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

        }