当下拉通知栏打开时,我希望点击此按钮。我希望它应该在那里,当我点击该按钮下拉菜单打开并将值0发送到SQL。
<li class="dropdown notifications-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-bell-o"></i>
<span class="label label-warning">10</span>
</a>
<ul class="dropdown-menu">
<li class="header">You have 10 notifications</li>
<li>
<!-- inner menu: contains the actual data -->
<ul class="menu">
<li>
<a href="#">
<i class="ion ion-ios-people info"></i> Notification title
</a>
</li>
...
</ul>
</li>
<li class="footer"><a href="#">View all</a></li>
</ul>
</li>
答案 0 :(得分:0)
<li class="dropdown notifications-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" id="updatevalue>
<i class="fa fa-bell-o"></i>
<span class="label label-warning">10</span>
</a>
<ul class="dropdown-menu">
<li class="header">You have 10 notifications</li>
<li>
<!-- inner menu: contains the actual data -->
<ul class="menu">
<li>
<a href="#">
<i class="ion ion-ios-people info"></i> Notification title
</a>
</li>
...
</ul>
</li>
<li class="footer"><a href="#">View all</a></li>
</ul>
</li>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#updatevalue").click(function(){
//Do your ajax works here.
$.ajax({url: "Your url", success: function(result){
//After success what you want to do. Do here
}});
});
});
</script>
希望你知道ajax。
答案 1 :(得分:0)
这是php Mysql的脚本在哪里把它放在ajax中???
<?php
$host = 'localhost';
$dbname = 'project';
$username = 'root';
$password = '1234';
$charset = 'utf8';
$d1 = $row7['userID'];
try {
$pdo = new PDO("mysql:host=$host;dbname=$dbname", $username, $password);
$usid = ($row['userID']);
$sql1 =
"SELECT
follow.followmak, follow.followrec, follow.date, follow.status , follow.time , tbl_users.userID , tbl_users.userName ,tbl_users.Fname , tbl_users.Lname
FROM
follow , tbl_users
WHERE
follow.followmak=tbl_users.userID
AND follow.followrec = $d1 AND follow.status = 1
ORDER BY
follow.time DESC";
$q1 = $pdo->prepare($sql1);
$q1->execute([$usid]);
$q1->setFetchMode(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
die("Could not connect to the database $dbname :" . $e->getMessage());
}
?>