Why won’t the JavaScript alerts pop up in an ASP classic Select Case branch?
When I put in the Response.End statements and run through the checkout process the JavaScript alert’s do their thing.. but when I take them out and they are immediately followed by a Redirect… the alerts do not popup. Any idea why?
If strResponse <> "000" Then
Select Case strResponse
Case "701"
%>
<script type="text/javascript">
alert("The customer is under 18 years of age based upon the date of birth.");
</script>
<%
'Response.End
Response.Redirect strRedirectCheckout
Case "702"
%>
<script type="text/javascript">
alert("The billing address is outside the United States.");
</script>
<%
'Response.End
Response.Redirect strRedirectCheckout
Case "707"
%>
<script type="text/javascript">
alert("The account holder does not have sufficient credit available for the transaction amount.");
</script>
<%
'Response.End
Response.Redirect strRedirectCheckout
Case Else
%>
<script type="text/javascript">
alert("Unable to obtain an authorization\nClick OK to be redirected back to checkout and please choose another form of payment");
</script>
<%
'Response.End
Response.Redirect strRedirectCheckout
End Select
Else ' if strResponse does == '000'; SUCCESS!!!
Because a Response.Redirect sends a message to the browser to start navigating to the page indicated. If you want them to see the popup first, after the alert just stay in JavaScript and use document.location.href=…..