dsb238100 2016-04-06 01:53
浏览 80

在ajax重新加载后,查询无法从url获取id

I create a button with ajax, when I click the button it will make an ajax request which executes a php file. The problem is I need to pass the URL Id into the php page in order to continue the query. When ajax reloads it just refreshes the div only so the system cannot get the ID.

Is there any solution to pass the ID into ajax side.

Here is the javascript

$('.like-btn').on('click',function(){
    var postID = $(this).attr("id");
    var user_id = $("#userID").val();
    var theclass = $(this).attr("class");
    var act= '';
    var tempScrollTop = $(window).scrollTop();
    if($(this).hasClass("like-h"))
    {
        act = 'unlike';
    }
    else if($(this).hasClass("unlike-h"))
    {
        act = 'like';
    }
    else
    {
        act = 'like';
    }
    $.ajax({
        type:"POST",
        url:"ajax/likeajax.php",
        data: {'act':act,'postID':postID,'uid':user_id},
        success: function(data){
            $("#viewprofile").load("viewviewprofile.php");
            $("#puid").val(data);
            $(window).scrollTop(tempScrollTop);
        }
    });

I cannot get the id with

$puid= $_GET['clickuid'];

This is the query

$puid = $_GET['clickuid'];
$query = mysqli_query($con,"SELECT * FROM status WHERE uid=$puid ORDER BY date DESC ");
  • 写回答

1条回答 默认 最新

  • dongtao5104 2016-04-06 01:59
    关注

    2 things:

    1) You are using POST and trying to access GET (either change your type to GET or change $_GET in php to $_POST)

    2) You're not passing the clickuid param

    评论

报告相同问题?

悬赏问题

  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算