tech4biz/assets/js/feedback-report.js
2024-10-24 17:20:08 +05:30

69 lines
2.5 KiB
JavaScript

(function ($) {
"use strict";
$("#experienceFeedbackForm").on("submit", function (event) {
event.preventDefault()
var feedback_title = $("#feedback_title").val();
var email = $("#email").val();
var description = $("#description").val();
// var image = $("#image").val();
var video = $("#video").val();
// var rating = $("#rating").val();
// var feedback_type = $("#feedback_type").val();
if (feedback_title == "" || email == "" || description == "" || video == "" // || image == "" // || rating == "" || feedback_type == ""
) {
formError();
submitMSG(false, "Did you fill up the form properly?");
}
else {
event.preventDefault();
submitForm();
setTimeout(() => {
window.location.reload();
}, 1000);
}
});
function submitForm() {
var feedback_title = $("#feedback_title").val();
var email = $("#email").val();
var description = $("#description").val();
// var image = $('#image')[0].files[0];
var video = $('#thirdVideo').val();
var rating = 0;
var feedback_type = $("#feedback_type").val();
$.ajax({
type: "POST",
url: "admin/api/feedback-report.php",
data: "feedback_title=" + feedback_title + "&email=" + email + "&description=" + description + "&thirdVideo=" + video + "&rating=" + rating + "&feedback_type=" + feedback_type,
success: function (text) {
if (text == "success") {
formSuccess();
} else {
formError();
submitMSG(false, text);
}
}
});
}
function formSuccess(event) {
event.preventDefault()
$("#experienceFeedbackForm")[0].reset();
submitMSG(true, "Feedback Submitted!")
}
function formError() {
$("#experienceFeedbackForm").removeClass().addClass('shake animated').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () {
$(this).removeClass();
});
}
function submitMSG(valid, msg) {
if (valid) {
var msgClasses = "h4 tada animated text-success";
} else {
var msgClasses = "h4 text-danger";
}
$("#msgSubmit").removeClass().addClass(msgClasses).text(msg);
}
}(jQuery));