I'm using vanilla JavaScript in this code. I created a variable of responseText and implement it on the if statement and even if condition A is true, it didn't work.
setInterval(()=>{
var http =new XMLHttpRequest();
http.open("GET","send.php",true);
http.setRequestHeader("Content-type","application/x-www-form-urlencoded");
http.onreadystatechange= function(){
if(http.readyState==4 && http.status==200){
var pu = http.responseText;
if(pu == "0"){
//do A
} else {
// Do B
}
}
}
http.send();
}, 1000)
The send.php file
<?php
session_start();
include"dbh.inc.php";
?>
<?php
$sqll = "SELECT * FROM `like-unlikes` WHERE `post_user`='".$_SESSION['username']."' AND `Stauts`=0";
$queryy = mysqli_query($conn, $sqll);
if($queryy){
if(mysqli_num_rows($queryy) > 0){
echo "0";
} else {
echo "1";
}
}
?>
Even if condition A is true it didn't work.