PDA

View Full Version : Real time jQuery notifications from a form?



xiphoid
03-09-2013, 11:11 AM
Hi,

I was wondering if it was possible, and if so, how I'd go about implementing this (http://akquinet.github.com/jquery-toastmessage-plugin/) notification plugin so that i can send notifications to my users via a form which is inside my admin panel.

Thanks

Beverleyh
03-09-2013, 01:18 PM
If you go to the demo and view the source code, you can see how to setup/configure the message in the head section of the web page, and then further down you can see how its called;
javascript:showSuccessToast();
You can attach the call to anything you like. So download the zip and install it by following the examples in the demo and also refer to the documentation on the wiki: https://github.com/akquinet/jquery-toastmessage-plugin/wiki

I'm not sure what you mean when you say that you want to send notifications to users via a form though.

If you mean that you want to send an email notification to their email inbox, this plugin can't do that (you'd need to use a server-side language such as php, rather than this which is client-side JavaScript)

If you just mean that you want to display a notification to a user (within the web page) while they use a particular form, this plugin can offer on-page feedback - maybe to say that something is loading or that a form is being submitted - you could attach a javascript call to a submit button. But even with the convenience if this javascript notifier, its still a good idea to display server-side feedback via php to confirm when an action has actually happened.

If you need more help, please provide a link to your page with the toast message scripts installed, and also give a clearer description of what you're having issues with and what you're trying to achieve.

xiphoid
03-09-2013, 01:42 PM
Thanks for the reply Beverley. What I basically want to do is have a form in an admin panel which the admin can enter a message and then click "submit" which would show the notification to all online users, for example if I wanted to alert all my online users of an important message I could enter the message in the form and submit it, resulting in it showing the notification to all the online users without a page reload, if that makes sense :P

Thanks

Beverleyh
03-09-2013, 02:27 PM
Ok - so how does your admin panel currently store the message? (Database? flat file?)

Are you just looking for help on how to pass an existing message variable to the toast popups?

xiphoid
03-10-2013, 09:54 AM
What I would be doing is storing the message in the database after it has been submitted. I know how to do that but I'm unsure of how I could get the message to show to all users without the need of a page reload.

Thanks very much :)

Beverleyh
03-10-2013, 11:29 AM
There's a method here using jQuery and AJAX that looks like it could work: http://stackoverflow.com/questions/8364541/update-a-div-automatically-with-jquery-when-new-record-added-in-mysql-database

I'm guessing that at the part of the function where it says;
if (results) { /* fade into dom */ }you could place the call to a toast popup message.