$(document).ready(function () {
//Update attraction
$("#update").click(function (event) {
event.preventDefault();
tinymce.triggerSave();
alert()
if (!$('#image').val() || $('#image').val().length === 0) {
swal({
title: "Error!",
text: "Please upload the image..!",
type: 'error',
timer: 1500,
showConfirmButton: false
});
} else if (!$('#caption').val() || $('#caption').val().length === 0) {
swal({
title: "Error!",
text: "Please enter the caption..!",
type: 'error',
timer: 1500,
showConfirmButton: false
});
} else {
var formData = new FormData($('#form-data')[0]);
$.ajax({
url: "post-and-get/blog-post-photo.php",
type: "POST",
data: formData,
async: false,
dataType: 'json',
success: function (result) {
swal({
title: "Success!",
text: "Your changes saved successfully!...",
type: 'success',
timer: 2000,
showConfirmButton: false
}, function () {
setTimeout(function () {
window.location.replace("edit-blog-post-photos.php?id=" + result.id);
}, 1500);
});
},
cache: false,
contentType: false,
processData: false
});
}
});
});
|