Skip to content

Instantly share code, notes, and snippets.

@markdaws
Created February 27, 2012 01:45
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 markdaws/1920625 to your computer and use it in GitHub Desktop.
Save markdaws/1920625 to your computer and use it in GitHub Desktop.
$(document).ready(function() {
status('Choose a file :)');
// Check to see when a user has selected a file
var timerId;
timerId = setInterval(function() {
if($('#userPhotoInput').val() !== '') {
clearInterval(timerId);
$('#uploadForm').submit();
}
}, 500);
$('#uploadForm').submit(function() {
status('uploading the file ...');
$(this).ajaxSubmit({
error: function(xhr) {
status('Error: ' + xhr.status);
},
success: function(response) {
//TODO: We will fill this in later
}
});
// Have to stop the form from submitting and causing
// a page refresh - don't forget this
return false;
});
function status(message) {
$('#status').text(message);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment