Skip to content

Instantly share code, notes, and snippets.

@kimjoar
Created July 13, 2012 19:57
Show Gist options
  • Select an option

  • Save kimjoar/3107025 to your computer and use it in GitHub Desktop.

Select an option

Save kimjoar/3107025 to your computer and use it in GitHub Desktop.
Step 1 -> 2
+function addStatus(options) {
+ $.ajax({
+ url: '/status',
+ type: 'POST',
+ dataType: 'json',
+ data: { text: $('#new-status textarea').val() },
+ success: function(data) {
+ $('#statuses ul').append('<li>' + data.text + '</li>');
+ $('#new-status textarea').val('');
+ }
+ });
+}
+
$(document).ready(function() {
$('#new-status form').submit(function(e) {
e.preventDefault();
- $.ajax({
- url: '/status',
- type: 'POST',
- dataType: 'json',
- data: { text: $('#new-status textarea').val() },
- success: function(data) {
- $('#statuses ul').append('<li>' + data.text + '</li>');
- $('#new-status textarea').val('');
- }
- });
+ addStatus();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment