我试图在IE11中使用JQuery进行Ajax发布。我已经修改了ie-9的兼容性元标记,但它仍然不起作用,不会发送帖子。相反,它会从jquery引发错误{exception} Unable to get property 'settings' of undefined or null reference
。
头
<head id="Head1">
<link href="../Content/Site.css" rel="stylesheet" type="text/css" />
<link href="../Content/datepicker.css" rel="stylesheet" type="text/css" />
<script src="/.../Scripts/jquery-1.8.2.min.js" type="text/javascript"></script>
<script src="/.../Scripts/jquery-ui-1.10.4.custom.min.js" type="text/javascript"></script>
<script src="/.../Scripts/json2.js" type="text/javascript"></script>
<script src="/.../Scripts/jquery.validate.min.js" type="text/javascript"></script>
<script src="/.../Scripts/jquery.validate.unobtrusive.min.js" type="text/javascript"></script>
<script src="/.../Scripts/UtilityFunctions.js" type="text/javascript"></script>
<script src="/.../Scripts/jquery-ui-1.11.0/jquery-ui.js"></script>
<meta http-equiv="X-UA-Compatible" content="IE=edge;chrome=1;IE=9;IE=8;IE=7" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="../Content/images/favicon.ico" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="-1" /></head>
jquery的
$('#EmailForm').validate({
invalidHandler: function(event, validator) {
var errors = validator.numberOfInvalids();
if (errors) {
var message = errors == 1
? '1 email field has a missing or invalid email address. It has been highlighted, please correct this or remove the field.'
: errors + ' email fields have missing or invalid email addresses. It has been highlighted, please correct this or remove the fields.';
$("div.error span").html(message);
$("div.error").show();
} else {
$("div.error").hide();
}
},
submitHandler: function (form) {
$(form).ajaxSubmit(function () {
history.go(-1);
});
}
});
$('body').on('click', '.remove_field', function () {
$(this).closest('p').remove();
});
$('.add_email_button').closest('p').click(function () {
var html = '<p><input type="email" class="email" form="EmailForm" required name="EmailAddresses" /><span class="btn_orange"><a href="#" class="remove_field">x</a></span></p>';
$(html).insertBefore($(this));
});
$('#SendEmail_Button').closest('span').click(function (e) {
e.preventDefault();
$('#EmailForm').submit();
@* if ($('#EmailForm').valid()) {
$.post('@Url.Action("PostEmail")', $('#EmailForm').serialize()).done(function() {
history.go(-1);
});
}*@
});
的web.config
<httpProtocol>
<customHeaders>
<clear/>
<add name="X-UA-Compatible" value="IE=IE9"/>
</customHeaders>
</httpProtocol>
答案 0 :(得分:1)
你需要做
$("#EmailForm").validate({
// options
});
,然后才能使用$("#EmailForm").valid()
。
对于历史运动,请在AJAX完成后执行:
submitHandler: function(form) {
$(form).ajaxSubmit(function() {
history.go(-1);
});
}