我的代码是在用户按下按钮后获取数据库中的特定项。如果找到该项目,我希望通过javascript显示确认消息,但我不知道如何显示它。
从数据库中获取项目后
if(null!=mysqli_fetch_array($res)))
{
echo ""; // how can I call the javascript code here ?
}和下面的确认框
<script type="text/javascript">
function onConfirm()
{
return confirm("Display this item ?");
}
</script>发布于 2012-05-14 23:01:47
使用jquery和ajax从数据库中获取值:
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
$.get("ajax.php", function(data){
if(data != "0"){
if(confirm("Display this item ?"))
{
//do something
}
}
});ajax.php:
//other db code here
if(null!=mysqli_fetch_array($res)))
{
echo "1";
}
else{
echo "0";
}https://stackoverflow.com/questions/10585840
复制相似问题