我在将PHP / MySQL代码实现为jgrowl时遇到问题。
如果您熟悉jgrowl,您会知道它会发送Growl为OS X提供的通知。
我试图让它从我的表中读取所有记录,但此刻它只显示一条记录作为通知,它循环通过它4次。
另一个问题是,如果我在表中有5行,那么jgrowl将只显示4个将要查看的通知。
如何让它查看表格中的所有记录作为通知?如何将记录总数(5)显示为通知并记录当前缺失的记录?
<script type="text/javascript">
// In case you don't have firebug...
if (!window.console || !console.firebug) {
var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
window.console = {};
for (var i = 0; i < names.length; ++i) window.console[names[i]] = function() {};
}
(function($){
$(document).ready(function(){
// This specifies how many messages can be pooled out at any given time.
// If there are more notifications raised then the pool, the others are
// placed into queue and rendered after the other have disapeared.
$.jGrowl.defaults.pool = 5;
var i = 1;
var y = 1;
setInterval( function() {
if ( i < <?php echo $totalRows_comment; ?> ) {
<?php
echo '$.jGrowl("'.$row_comment['comment'].'",';
?>
{
sticky: true,
log: function() {
console.log("Creating message " + i + "...");
},
beforeOpen: function() {
console.log("Rendering message " + y + "...");
y++;
}
});
}
i++;
} , 1000 );
});
})(jQuery);
</script>
<p>
</span>
<p>
答案 0 :(得分:1)
你的问题肯定不在于获取行 所有这些问题都源于同一根:目标不明确。您想要获得哪些JavaScript代码?
你必须将你的工作分为两部分并分别完成:
除了PHP和MySQL之外,还要编写你的Growl或其他任何代码并调试它直到它开始工作。每一点数据都必须硬编码,就像根本没有PHP和mysql一样,你的数据是静态的。
一旦你(1)工作,最简单的部分将保留:只需编写一个PHP / MySQL代码,生成你的javascript代码的精确副本。没什么大不了的。
就是这样 只是不要坐在2个凳子之间 希望这有帮助