Last active
August 29, 2015 14:17
-
-
Save high5/92c5027388fdbd544785 to your computer and use it in GitHub Desktop.
execute ajax on flux action sample
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
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