After submitting form to jQuery show the orignal DIV contents after some time
I'm new to the whole jQuery stuff and really like it! I'm really a graphic designer but like this sort of coding two!
I'm currently creating a simple shoutbox system. The whole shoutbox is in one DIV (shout_box). The DIV shows the 8 latest posts and below that you can enter a new shout / post. I used some script to submit the new post to a PHP page which fetches the data using Post. Then the script displays the message that the post has been added.
This works great! However after 5 seconds I want the original DIV contents to reload (the 8 latest posts and the form to add posts. is that possible to do? I think it is, but don't really now where to begin.
I currently got the code below:
- var dataString = 'message='+ message;
- //alert (dataString);return false;
- $.ajax({
- type: "POST",
- url: "bin/process_msb.php",
- data: dataString,
- success: function() {
- $('#shout_box').html("<div id='message'></div>");
- $('#message').html("<p align='center'><img src='../images/loading.gif' title='Uw bericht wordt geplaatst...'> Uw bericht wordt geplaatst...</p>")
- .hide()
- .fadeIn(500, function() {
- $('#message');
- });
- }
- });
- return false;