You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
78 lines
1.8 KiB
78 lines
1.8 KiB
function postPhoto(data){
|
|
if (data.success){
|
|
window.location.reload();
|
|
}
|
|
else{
|
|
console.log(data);
|
|
}
|
|
|
|
}
|
|
|
|
function postHall(data){
|
|
if (data.success){
|
|
window.location.reload()
|
|
}
|
|
else{
|
|
console.log(data);
|
|
}
|
|
}
|
|
|
|
function deleteHall(data){
|
|
if (data.success){
|
|
window.location.reload();
|
|
}
|
|
else{
|
|
console.log(data);
|
|
}
|
|
}
|
|
|
|
function deletePhoto(data){
|
|
if (data.success){
|
|
window.location.reload();
|
|
}
|
|
else{
|
|
console.log(data);
|
|
}
|
|
}
|
|
|
|
$(document).ready(function(){
|
|
$('#photo_form').on('submit', function(e){
|
|
e.preventDefault();
|
|
var url = $(this).attr('action');
|
|
var fileData = new FormData($(this)[0]);//file (request.FILES)
|
|
var formData = $(this).serialize();// another data (request.POST)
|
|
$.ajax({
|
|
url: url, //server script to process data
|
|
type: 'POST',
|
|
|
|
//Ajax events
|
|
success: postPhoto,
|
|
error: function(){ alert('error'); },
|
|
// Form data
|
|
data: (formData, fileData),
|
|
//Options to tell JQuery not to process data or worry about content-type
|
|
cache: false,
|
|
contentType: false,
|
|
processData: false
|
|
});//end ajax
|
|
});
|
|
|
|
$('#hall_form').on('submit', function(e){
|
|
e.preventDefault();
|
|
var url = $(this).attr('action');
|
|
var formData = $(this).serialize();
|
|
$.post(url, formData, postHall);
|
|
});
|
|
$('.delete-hall').on('click', function(e){
|
|
e.preventDefault();
|
|
var url = $(this).attr('href');
|
|
$.get(url, deleteHall);
|
|
});
|
|
$('.delete-photo').on('click', function(e){
|
|
e.preventDefault();
|
|
var url = $(this).attr('href');
|
|
$.get(url, deletePhoto);
|
|
});
|
|
|
|
});
|
|
|
|
|