ajax防止页面刷新,JQuery Ajax Force页面刷新

我这里有一个接受用户凭据的表单。如果用户具有无效的用户凭据,则页面将无法加载,但是如果他或她具有有效凭据,我希望页面进行整页刷新,我将如何实现?我试过添加。

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 here

window.location.href = window.location.href;

但页面没有重新加载。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值