Skip to content

Instantly share code, notes, and snippets.

@high5
Last active August 29, 2015 14:17
Show Gist options
  • Save high5/92c5027388fdbd544785 to your computer and use it in GitHub Desktop.
Save high5/92c5027388fdbd544785 to your computer and use it in GitHub Desktop.
execute ajax on flux action sample
var TodoActions = {
/**
* @param {string} text
*/
create: function(text) {
$.ajax({
cache:false,
type: "POST",
url: "/todos",
data: { title: text}
})
.done(function(msg) {
AppDispatcher.dispatch({
actionType: TodoConstants.TODO_CREATE,
id : msg,
text: text
});
})
.always(function( jqXHR, textStatus ) {
});
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment