我正在尝试创建一个用户系统,但是有一部分代码无法执行。我正在使用ajax将值传递给PHP,但是这个块只是没有执行,我不明白为什么。
PHP
<?
/* New Follower */
include_once("php/check_user_log.php");
include_once("php/db_conx.php");
if(isset($_POST["follower"])){
echo "success_1";
if ($_POST["follower"] == "yes"){
echo "success_2";
$follower_id = $log_id;
$following_id = $_GET["u"];
echo "success_3";
$curr_followers = $followers;
$new_followers = $curr_followers.",".$follower_id;
echo "success_4";
$follower_update = "UPDATE users SET followers='$new_followers' WHERE username=$following_id";
$query = mysqli_query($db_conx, $follower_update);
echo "success_5";
$follower_sql = "SELECT * FROM users WHERE id='$log_id' AND activated='1' LIMIT 1";
$follower_query = mysqli_query($db_conx, $follower_sql);
echo "success_6";
while ($row = mysqli_fetch_array($follower_query, MYSQLI_ASSOC)) {
$follower_following = $row["following"];
}
echo "success_7";
$curr_following = $follower_following;
$new_following = $curr_following.",".$following_id;
echo "success_8";
$following_update = "UPDATE users SET following='$new_following' WHERE id=$log_id";
$query1 = mysqli_query($db_conx, $following_update);
echo "success_9";
} else {
echo "fail_1";
exit();
}
}
/* End New Follower */
?>
的Javascript
function newFollower(){
var new_follower = "yes";
if(new_follower == ""){
$(".logo").html("new_follower not set");
} else {
var ajax = ajaxObj("POST", "profile.php");
ajax.onreadystatechange = function() {
if(ajaxReturn(ajax) == true) {
if (ajax.responseText == "success_1"){
$(".logo").html("success_1");
} else if (ajax.responseText == "success_2"){
$(".logo").html("success_2");
} else if (ajax.responseText == "success_3"){
$(".logo").html("success_3");
} else if (ajax.responseText == "success_4"){
$(".logo").html("success_4");
} else if (ajax.responseText == "success_5"){
$(".logo").html("success_5");
} else if (ajax.responseText == "success_6"){
$(".logo").html("success_6");
} else if (ajax.responseText == "success_7"){
$(".logo").html("success_7");
} else if (ajax.responseText == "success_8"){
$(".logo").html("success_8");
} else if (ajax.responseText == "success_9"){
$(".logo").html("success_9");
} else if (ajax.responseText == "fail_1"){
$(".logo").html("fail_1");
} else if (ajax.responseText == "fail_2"){
$(".logo").html("fail_2");
} else {
$(".logo").html("unknown error");
}
}
}
ajax.send("follower="+new_follower);
}
}
如果您还想知道其他任何事情,请问我不完全确定您需要哪些信息。
答案 0 :(得分:0)
谢谢肖恩。您对ajax打开页面profile.php的评论不是当前页面的问题。