PDA

View Full Version : Js Alert() doesn't work in IE?



Lukeas
Mar 21st, 2013, 07:36 AM
Hi, Sorry to ask a question with my first post, but here it is.

I have the following script to show a js alert box on the successful completion/submission of a contact form. On chrome and firefox it displays ok but with IE, nothing is shown.

Any ideas?

Thx for any suggestions/help.


$.ajax({

url: '/*****/modules/contact_us/ContactUsProcess.class.php',
type: 'POST',
cache:false,
data: $('#frmContactUs').serialize(),
success: function(data) {
if (data == 'success') {
alert('successful submission');
$('#frmContactUs')[0].reset();
} else {
alert(data);
}
}
});

}

devnull69
Mar 21st, 2013, 09:30 AM
This piece of code is just fine ... you should try to observe the request using the development tools of your choice and adding an "error" callback



$.ajax({

url: '/*****/modules/contact_us/ContactUsProcess.class.php',
type: 'POST',
cache:false,
data: $('#frmContactUs').serialize(),
success: function(data) {
if (data == 'success') {
alert('successful submission');
$('#frmContactUs')[0].reset();
} else {
alert(data);
}
},
error: function(jqXHR, textStatus, errorThrown) {
alert('Error: ' + errorThrown + ' (' + jqXHR.status + ' / ' + textStatus + ')');
}
});

felgall
Mar 21st, 2013, 09:53 AM
Just don't forget to replace the debugging alerts once you have finished debugging. There should be no alerts in the code when it goes live as they allow disabling JavaScript or further alerts (depending on which browser is being used) to make debugging easier.

glenngv
Mar 21st, 2013, 09:42 PM
You may need to specify dataType option.