mirror of
https://github.com/mgerb/mywebsite
synced 2026-01-11 18:32:50 +00:00
61 lines
1.7 KiB
JavaScript
61 lines
1.7 KiB
JavaScript
|
|
$('#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
|
|
});
|
|
}); |