Slide 74
Slide 74 text
jQuery(function($) {
$('form').on('submit', function() {
$.ajax({
url: '/statuses',
type: 'POST',
dataType: 'json',
data: {text: $(this).find('textarea').val()},
success: function(data) {
$('#statuses').append('
' + data.text + '');
}
});
return false;
});
});
Violates is so many ways
Bound to page loading, so you only have one chance to test it
Tied to form submission, so you have to do that
Requires network activities, a textarea to have been filled in, an event triggered by successful
ajax, and finally HTML templating.