I'm trying to POST a form from my website to a server (not same domain).
Everything is working fine with Chrome, Firefox and IE10+, but I have to make it work with IE9 too.
Here's my code
$("#sendform").click(function() {
// Content
var infosForm = {};
infosForm.firstname = $('input[name=firstname]')[0].value;
infosForm.name = $('input[name=name]')[0].value;
infosForm.phone = $('input[name=tel]')[0].value;
infosForm.mail = $('input[name=mail]')[0].value;
infosForm.commentaire = $('textarea[name=comment]')[0].value;
var isChecked = $('.messageCheckbox:checked').val();
if (isChecked == "on")
{
infosForm.isNewsletter = "on";
}
else
{
infosForm.isNewsletter = "off";
}
$.ajax({
url:'http://my.website.com/form.ashx',
type:'post',
data:infosForm,
cache:false, //normaly this is quite useless since it's a post, but It's known to help with IE... still not.
crossDomain:true,
//showing feedback
success:function(){
$("#contact form").hide();
$("#contact form").fadeIn('slow').html("
Success
");//trackEvent();
},
error:function(){
$("#contact form").hide();
$("#contact form").fadeIn('slow').html("
Error
");}
});
});
According to fiddler, it seems like IE9 isn't sending any request and going straight to showing the error message.
Note : jQuery 1.8.3 is used here.