Created
May 28, 2010 18:05
-
-
Save JshWright/417495 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function append_message(data) { | |
fields = data[0].fields; | |
message_str = fields.msg + '\nPosted by: <strong>' | |
+ fields.posted_by + '</strong> on: ' | |
+ fields.timestamp; | |
new_div = $('<div />').addClass('message').html(message_str); | |
$('div#current_messages').append(new_div); | |
} | |
$('#msgform').submit(function() { | |
$.post('/ajaxsubmit', | |
{posted_by: $("input[name='posted_by']").val(), | |
msg: $("textarea[name='msg']").val()}, | |
append_message, 'json'); | |
//For brevity, we're just going to assume this always works | |
$("textarea[name='msg']").val(''); | |
return false; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment