I have a Login popup form where I use an ajax post request to Login.asp script in order to prevent the page from going to the POST URL after submission.
<script>
$(function() {
$('#contactForm').submit(function(e){
e.preventDefault();
$.ajax({
url:'/ASPLogin/Login.asp',
type:'POST',
data:$('#contactForm').serialize(),
dataType:'text',
success: function(response)
{
var temp = new Array();
temp = response.split("|");
if (temp[0] == 'something') {
}
else {
$("#response").html(response);
}
}
});
});
});
</script>
in Login.asp
If OK Then
response.redirect("/index.asp?token=" & str)
Else
response.write("error")
End If
So when login is wrong, I display an Error message in the popup form. If login is successful, I need to close the popup form and redirect.
The issue is that I am getting redirected page sources inside my popup form.
I have tried doing it this way:
If OK Then
response.write("<script>$('#closeBut').click();</script>")
response.redirect("/index.asp?token=" & str)
Else
response.write("error")
End If
While the popup is closed, the page is not being redirected properly.
I also attempted the following:
If OK Then
response.write("<script>$('#closeBut').click();</script>")
Response.Write("<script>window.location.href = " & "'/index.asp?token=" & str & "';</script>")
Else
response.write("error")
End If
Even though the popup is closed, the page is still not being redirected as expected.
How can I resolve this issue? How do I successfully close the popup and redirect the page normally?