我这里有一个接受用户凭据的表单。如果用户具有无效的用户凭据,则页面将无法加载,但是如果他或她具有有效凭据,我希望页面进行整页刷新,我将如何实现?我试过添加。
window.location.href = window.location.href;
在响应html但它没有用,似乎jquery正在删除脚本代码?
这是表单提交的AJAX。
$('body').on('submit', '#sign-in', function(e) {
e.preventDefault();
var data = $(this).serialize();
var url = $(this).attr('action');
$.ajax({
//this is the php file that processes the data and send mail
url : url,
type : "POST",
data : data,
//Do not cache the page
cache : false,
//success
success : function(data) {
alert(data);
$('#loginModal').html($(data).find('#loginModal').html());
}
});
})
如果用户具有有效凭据,则成功的响应将是此
Insert title herewindow.location.href = window.location.href;
但页面没有重新加载。