0
在我的數據庫中,我打算創建一個存儲消息的表來提醒用戶需要做的任何事情。在PHP和MySQL中使用jQuery Growl
我正在尋找使用jQuery咆哮像通知方法,但我很困惑我將如何開始構建它。
數據將從表單中使用標準的MySQL插入方法添加到數據庫中,但是如何從數據庫中選擇消息以使用jQuery咆哮顯示。
這是否需要使用AJAX?
這是JavaScript代碼,我到目前爲止,我不知道我將如何實現PHP代碼在它旁邊,這樣我可以從我的桌子拉出來的數據顯示爲通知:
<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 < 3) {
$.jGrowl("Message " + i, {
sticky: true,
log: function() {
console.log("Creating message " + i + "...");
},
beforeOpen: function() {
console.log("Rendering message " + y + "...");
y++;
}
});
}
i++;
} , 1000);
});
})(jQuery);
</script>
<p>
</span>
<p>