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 ");