mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-12 02:42:48 +00:00
changed file uploads
This commit is contained in:
61
public/javascript/upload.js
Normal file
61
public/javascript/upload.js
Normal file
@@ -0,0 +1,61 @@
|
||||
|
||||
$('#newpost-form').click(function(evt){
|
||||
evt.preventDefault();
|
||||
|
||||
var formData = new FormData($('form')[0]);
|
||||
$.ajax({
|
||||
url: '/newpost', //Server script to process data
|
||||
type: 'POST',
|
||||
|
||||
//Ajax events
|
||||
beforeSend: function(){
|
||||
$('body').addClass("loading");
|
||||
$('#response').text("Uploading...");
|
||||
},
|
||||
success: function(data){
|
||||
$('body').removeClass("loading");
|
||||
$('#response').text(data);
|
||||
},
|
||||
error: function(err){
|
||||
$('body').removeClass("loading");
|
||||
$('#response').text("Error Uploading");
|
||||
},
|
||||
// Form data
|
||||
data: formData,
|
||||
//Options to tell jQuery not to process data or worry about content-type.
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
$('#upload-form').click(function(evt){
|
||||
evt.preventDefault();
|
||||
|
||||
var formData = new FormData($('form')[0]);
|
||||
$.ajax({
|
||||
url: '/upload', //Server script to process data
|
||||
type: 'POST',
|
||||
|
||||
//Ajax events
|
||||
beforeSend: function(){
|
||||
$('body').addClass("loading");
|
||||
$('#response').text("Uploading...");
|
||||
},
|
||||
success: function(data){
|
||||
$('body').removeClass("loading");
|
||||
$('#response').text(data);
|
||||
},
|
||||
error: function(err){
|
||||
$('body').removeClass("loading");
|
||||
$('#response').text("Error Uploading");
|
||||
},
|
||||
// Form data
|
||||
data: formData,
|
||||
//Options to tell jQuery not to process data or worry about content-type.
|
||||
cache: false,
|
||||
contentType: false,
|
||||
processData: false
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user