Refactored the repository and gruntified all the things
This commit is contained in:
40
websrc/js/main.js
Normal file
40
websrc/js/main.js
Normal file
@@ -0,0 +1,40 @@
|
||||
$("#contactform").submit(function(e) {
|
||||
e.preventDefault();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
dataType: "json",
|
||||
contentType: "application/x-www-form-urlencoded",
|
||||
url: "/minewatch/submit.php",
|
||||
|
||||
headers: {
|
||||
"Accept" : "application/json"
|
||||
},
|
||||
data: {
|
||||
name: $("#form_name").val(),
|
||||
email: $("#form_email").val(),
|
||||
reason: $("#form_reason").val(),
|
||||
feedback: $("#form_feedback").val()
|
||||
}
|
||||
}).done(function(response) {
|
||||
var data = response.data;
|
||||
if(response.success) {
|
||||
$.ajax({
|
||||
url:"/minewatch/includes/success.php"
|
||||
}).done(function(response) {
|
||||
var thanks = $(response);
|
||||
thanks.hide();
|
||||
$("#contactform").fadeOut("fast",function() {
|
||||
$(this).replaceWith(thanks);
|
||||
thanks.fadeIn("fast");
|
||||
})
|
||||
});
|
||||
} else {
|
||||
if(data.name == "") $("#form_name").addClass("red");
|
||||
if(data.email == "") $("#form_email").addClass("red");
|
||||
if(data.feedback == "") $("#form_feedback").addClass("red");
|
||||
}
|
||||
});
|
||||
});
|
||||
$("#contactform input, #contactform textarea").blur(function() {
|
||||
if($(this).val().length>0) $(this).removeClass("red");
|
||||
});
|
||||
Reference in New Issue
Block a user