Created
January 13, 2013 19:49
-
-
Save vsergeyev/4525875 to your computer and use it in GitHub Desktop.
Ajax upload of file with bootbox popup
This file contains hidden or 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
bootbox.upload("Choose file", "/file_upload/", function($form) { | |
if (!$form) return; | |
var form_data = new FormData(); | |
form_data.append("file", $form.find("input[type='file']")[0].files[0]); | |
$.ajax({ | |
url: $form.attr("action"), | |
processData: false, // Important! | |
contentType: false, // Important! | |
data: form_data, | |
type: $form.attr("method"), | |
success: function(data, text) { | |
data = JSON.parse(data); | |
console.log("File uploaded"); | |
}, | |
error: function() { | |
console.log("Server error or no connection. Please try again."); | |
} | |
}); | |
}); | |
} |
Hello vsergeyev, which 'bootbox.upload()' function are you referring to?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Top!