警告我有一个按钮:防止 '确认导航' 与window.location.href
<button type="button" class="btn btn-primary mt15 send-emails" name="SendEmails" value="true">Send Emails</button>
与方法:
$('.send-emails').click(function (e) {
// build data and other stuff
$.post('/leads/sendemails', data, function (data, status, xhr) {
alert('Emails have successfully been queued for sending.');
window.onbeforeunload = null;
window.location.href = '/Leads/Lead/' + @Model.LeadID;
}, 'json');
});
即使window.onbeforeunload = null;
我仍然得到弹出警告:
我如何避免这种情况?
请试试这个:'$(window).unbind();' –
工作正常!列出它作为答案? –