我正在尝试将用户投票更新为数据库。下面的ajax代码可返回正确的评分数据。但是,我无法在另一页上获得警报数据。在我的car_user_rating.php页面中,我尝试了此echo $post_rating = $_POST['performance_rating'];。但是它没有获得Performance_rating数据值。

我已经检查了控制台。它返回额定值(4)。我很困惑为什么它无法获得数据值?

ajax请求



$(function () {
    $('#form').on('submit', function (e) {
      performance_rating = $('input:radio[name=rating]:checked').val();
      e.preventDefault();
      $.ajax({
        type: 'POST',
        url: "<?=CAR_USER_RATINGS?>",
        data: { performance_rating: performance_rating },
        success : function(data){
            alert(performance_rating)
         },
      });
    });
});

最佳答案

您应该提醒您在data中传递的success: function()

喜欢

     success : function(response){
        alert(response);
     },

关于javascript - 无法获取另一页上的ajax的数据值,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25360904/

10-12 13:30
查看更多