jQuery Ajax强制页面刷新

I have here a form where that accepts user credentials. if the user has invalid user credentials the page will not load however if he or she has valid credentials I want the page to do full page refresh how would I achieve that? I have tried adding.

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

On the response html but it did not work, it seems like jquery is removing the script code?

here's the AJAX for form submission.

$('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());
        }
    });
})

if the user has valid credentials the response from the success would be this

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<script>
    window.location.href = window.location.href;

</script>
</head>

but the page is not reloading.

See if you can use this code in the success function

On receiving valid response (like 1)

$(document).attr('location').href='your location'

In the success function you can use the JavaScript way to reload :

location.reload();

A bit like this

$('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,
        //login success
        success : function(data) {
            //... your other code
            location.reload(); //reload the page on the success
        }
    });
})

That implies that your query thorws an error when the login fails so it doesn't go in your success function.