using jquery growl with php/mysql
Posted
by jeansymolanza
on Stack Overflow
See other posts from Stack Overflow
or by jeansymolanza
Published on 2010-05-25T00:34:12Z
Indexed on
2010/05/25
0:41 UTC
Read the original article
Hit count: 382
on my database i am planning to create a table storing messages to alert users of anything they need to do.
i am looking at using a jQuery growl like notification method but im confused at how i would begin building it.
the data would be added into the database using the standard MYSQL insert method from a form but how would i select messages from the database to display using the jQuery growl.
would this require the use of ajax?
this is the javascript code i have so far, i was wondering how i would implement the php code alongside it so that i can pull out data from my tables to display as notifications:
<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>
thanking you in advance and God bless
© Stack Overflow or respective owner