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.