Php 动态下拉菜单不工作

Php 动态下拉菜单不工作,php,jquery,session,Php,Jquery,Session,我试图使通知选项卡工作,但似乎没有得到它的权利。下拉列表工作正常,但ajax调用工作不正常,当使用firebug查看时,会有结果,但在下拉列表中看不到。非常混乱。(注意,下拉菜单位于标题中,只有在初始化会话时才能显示)以下是jquery中使用的ajax: function load_notifications(view=''){ $.ajax({ url: "notification/new_friends.php", method: "POST",

我试图使通知选项卡工作,但似乎没有得到它的权利。下拉列表工作正常,但ajax调用工作不正常,当使用firebug查看时,会有结果,但在下拉列表中看不到。非常混乱。(注意,下拉菜单位于标题中,只有在初始化会话时才能显示)以下是jquery中使用的ajax:

function load_notifications(view=''){
   $.ajax({
       url: "notification/new_friends.php",
       method: "POST",
       data:{view:"view"},
       dataType:"json",
       success: function(data){

           $(".dropdown-menu").html(data.notification);
if(data.unseen_notification>0){
    $(".badge1").html(data.unseen_notification);
}
    }

   });
        //$(".dynamic-notification").load("notification/pm_n.php");
   // $(".dynamic-notification-f").load("notification/new_friends.php");
};
load_notifications();
$(document).on("click",".count_friend", function(){
    load_notifications('yes');
});
//loads every 2 seconds for chat
setInterval(function(){load_notifications();},2000);
以下是新的_friends.php内容:

<?php
include '../includes/dbconfig.inc.php';

if (isset($_POST['view'])) {

if($_POST['view'] !=''){
$update="update friends set count='1' where friend_one=:session and count='0'";
$stmt=$conn->prepare($update);
$stmt->bindValue(":session", $_SESSION['uname']);
$stmt->execute();
}
$sql123="select id from friends where friend_two=:sess_uname and count='0'";
$stmt123=$conn->prepare($sql123);
$stmt123->bindValue(":sess_uname", $_SESSION['uname']);
$stmt123->execute();
$request_count=$stmt123->fetchColumn();
//$count_friend=$stmt123->rowCount();
/*$sql_f_count="select *from user where user_id=:session_id and activated='1' limit 1";
$stmt_f_count=$conn->prepare($sql_f_count);
$stmt_f_count->bindValue(":session_id", $_SESSION['id']);
$stmt_f_count->execute();
$user_details=$stmt_f_count->fetchAll();
$friend_badge=$user_details[0]['friend_count_badge'];*/
require "notification/friend_request_notification.php";
// $new_friends="<span class='dropdown'><a href='#' data-placement='bottom' class='btn dropdown-toggle' data-toggle='dropdown' title='Friend Requests' data-html='true'><span class='count_friend' style=' height:33px; width:30px;'><span class='badge1 label label-pill'>".$count."</span><img src='img/logo/group-button-white.png' style='height:25px; width:27px;' alt='new_friends_alert'></span></a><ul class='dropdown-menu'></ul></span>"; 
//if($request_count[0]>0){
//$new_friends="<a href='#' data-placement='bottom' class='btn' data-trigger='focus' title='Friend Requests' data-toggle='popover' data-html='true' data-content='".$friend_requests."'><span class='count_friend' style=' height:33px; width:30px;'><img src='img/logo/group-button-white.png' style='height:25px; width:27px;' alt='new_friends_alert'></span><span class='badge'>".$friend_badge."</span></a>";
/*}else{
$new_friends="<a href='all_notifications.php'><img src='img/logo/group-button-black.png' style='height:25px; width:27px;' alt='new_friends_alert'></a>";
}*/
//echo $new_friends;
//}
$data=array(
'notification'=>$friend_requests,
'unseen_notification' =>$request_count[0][0]
);

这里是下拉列表,如果您能提供帮助:

<?php
// Assume $db is a PDO object

$dbh = new PDO('mysql:host=localhost;dbname=populatedropdown', "root", "");

$query = $dbh->query("select * from position"); // Run your query

echo '<form action="populate.php" method="get">';
echo '<select name="populate">'; // Open your drop down box



// Loop through the query results, outputing the options one by one
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
   echo '<option value="'.$row['id'].'">'.$row['name'].'</option>';
}

echo '</select>';// Close your drop down box


echo '<input type="submit" name="edit" value="Edit">';

echo '</form>';
?>

这里是下拉列表,如果您能提供帮助:

<?php
// Assume $db is a PDO object

$dbh = new PDO('mysql:host=localhost;dbname=populatedropdown', "root", "");

$query = $dbh->query("select * from position"); // Run your query

echo '<form action="populate.php" method="get">';
echo '<select name="populate">'; // Open your drop down box



// Loop through the query results, outputing the options one by one
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
   echo '<option value="'.$row['id'].'">'.$row['name'].'</option>';
}

echo '</select>';// Close your drop down box


echo '<input type="submit" name="edit" value="Edit">';

echo '</form>';
?>


我认为我的意图不同,我的php代码还行,我认为是jquery造成了问题。由于firebug输出了所需的json代码,但我的通知和json中未显示的_通知值没有填充到下拉菜单类中。我认为我的意图不同,我的php代码没有问题,我认为是jquery造成了问题。当firebug输出所需的json代码时,json中的my notification和unseen_notification值不会填充到下拉菜单类中。