Within my script, an AJAX call is being made as follows:
(function() {
var setup, validation;
var errorMessage = '';
var errorClass = '';
var element = '';
var errorElement = '';
var allOk = true;
var testTelefon = /^[0-9\-+]{2,40}$/;
var testEpostAdress = /^(?!.{65})\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
(function() {
setup = {
init: function() {
this.initSendForm();
},
initSendForm: function() {
var self = this;
$('#helpContactForm').submit(function(event) {
if (allOk) {
var formData = self.getFormData();
var url = $(this).attr("action");
$.ajax({
cache: false,
type: "POST",
url: url,
data: formData,
success: function(data) {
if (data.Success) {
self.resetFormData();
self.showModal(data);
}
},
error: function(data) {
self.showModal(data);
}
});
}
self.hideModal();
event.preventDefault();
});
},
getFormData: function() {
var data = {
'Namn': $('#namn').val(),
'Email': $('#epost').val(),
'Telefon': $('#telefon').val(),
'Fraga': $('#fraga').val()
};
return data;
},
resetFormData: function() {
$('#namn').val(''),
$('#epost').val(''),
$('#telefon').val(''),
$('#fraga').val('')
return true;
},
...and the code goes on.
This "contact us" form works in all browsers, except IE 11 and below. In IE, when the form is submitted, it prompts the user to download the JSON response instead of showing it in a Bootstrap modal as intended.
The console error in IE is showing a ") expected" message, indicating a syntax error. I have reviewed the code multiple times and could not find any missing parentheses. This issue seems to be specific to IE.
It's possible that there are interrelated problems or something crucial missing in the AJAX request block causing IE to handle the response differently. The parenthesis error might be linked to another issue.
If anyone has insights or suggestions on how to resolve this IE-specific behavior, your help would be greatly appreciated!
Update: The complete code is now consolidated in one file for better visibility. Any further assistance is welcomed.