after going through hundreds of questions, none of the solutions offered have solved my problem. My issue is simple, I have a Joomla module for sending emails. While creating the module on a live server with joomla 3.5.1, all was well but when I installed in another live joomla website in a different server, it does not end any email. Whats weird is that the all other functions in the script works well apart from $.ajax({
which is essentially responsible for sending data to the server. I had initially thought the error was occurring in the server side but upon sending the email without jQuery, everything works perfectly. My code is as below.
<script type="text/javascript">
jQuery(document).ready(function ($) {
$('#dock_send').click(function (e) {
//First we do some validation,
$("#dock_sending").removeClass("hide");
alerts = '';
if ($("input[name=dock_skibzy_names]").val() == '') {
alerts += "1";
$("#dock_error_name").addClass("error");
}
if ($("input[name=dock_skibzy_email]").val() == '') {
alerts += "1";
$("#dock_error_email").addClass("error");
}
if (!validateEmail($("input[name=dock_skibzy_email]").val())) {
alerts += "1";
$("#dock_error_email").addClass("error");
}
if ($("input[name=dock_skibzy_phone]").val() == '') {
alerts += "1";
$("#dock_error_phone").addClass("error");
}
if (!validateNumber($("input[name=dock_skibzy_phone]").val())) {
alerts += "1";
$("#dock_error_phone").addClass("error");
}
if ($("input[name=dock_skibzy_subj]").val() == '') {
alerts += "1";
$("#dock_error_subj").addClass("error");
}
if ($("select[name=dock_skibzy_subj_cat]").val() == '' && $("input[name=dock_cat_vis]").val() == 'yes') {
alerts += "1";
$("#dock_error_subj_cat").addClass("error");
}
if ($("textarea[name=dock_skibzy_msg]").val() == '') {
alerts += "1";
$("#dock_error_msg").addClass("error");
}
if ($("textarea[name=dock_skibzy_msg]").val().length < 10) {
alerts += "1";
$("#dock_error_msg").addClass("error");
}
if (alerts != '') {
$("#dock_sending").addClass("hide");
} else {
$.ajax({
url: 'index.php',
type: 'POST',
contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
data: $("#dock_skibzy_form").serialize(),
cache: false,
success: function (data) {
show_ok();
},
error: function () {
$("#msg_not_sent").removeClass("hide");
$("#dock_sending").addClass("hide");
}
});
}
e.preventDefault();
});
$("#dock_skibzy_names").click(function (e) {
e.preventDefault();
$("#dock_error_name").removeClass("error");
});
$("#dock_skibzy_email").click(function (e) {
e.preventDefault();
$("#dock_error_email").removeClass("error");
});
$("#dock_skibzy_phone").click(function (e) {
e.preventDefault();
$("#dock_error_phone").removeClass("error");
});
$("#dock_skibzy_subj").click(function (e) {
e.preventDefault();
$("#dock_error_subj").removeClass("error");
});
$("#dock_skibzy_subj_cat").click(function (e) {
e.preventDefault();
$("#dock_error_subj_cat").removeClass("error");
});
$("#dock_skibzy_msg").click(function (e) {
e.preventDefault();
$("#dock_error_msg").removeClass("error");
});
$("#msg_sent").click(function (e) {
e.preventDefault();
$("#dock_msg_sent").addClass("hide");
$("#dock_sending").addClass("hide");
});
function show_ok() {
$("#dock_sending").addClass("hide");
$("#dock_msg_sent").removeClass("hide");
$("input").val('');
$("select").val('');
$("textarea").val('');
}
function validateEmail($email) {
var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
return emailReg.test($email);
}
function validateNumber($num) {
var intReg = /^\d+$/;
return intReg.test($num);
}
});
</script>