Skip to content

Instantly share code, notes, and snippets.

@isaacs
Created July 13, 2012 02:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isaacs/3102355 to your computer and use it in GitHub Desktop.
Save isaacs/3102355 to your computer and use it in GitHub Desktop.
document.getElementById('myform').onsubmit = blerg
function blerg(e) {
var name = document.querySelector('input').value
if (!name) {
// If there's no name, then we have nothing to post!
// skip right over the post bit, to the validate bit!
return validate()
}
request({
uri: "http://example.com/upload",
body: name,
method: "POST"
}, postResponse)
}
function postResponse (er, response, data) {
dataGlorpBlerg()
validate()
}
function validate () {
// either we came through postResponse, or we didn't
// the logic joins back up.
vargleValidargle()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment