我有一个 JSP 页面,我用它来重定向到另一个 url(跨域),所以使用 jQuery 我放置了一个按钮单击事件,在该事件下 response.sendRedirect 应该触发,但是一旦页面加载它就会重定向它甚至不等待为警觉。这里有什么问题?请帮忙。
在身体负载上,它调用 load()
<script language="JavaScript">
function load(){
<%
String message=(String)request.getAttribute("error");
if(message != null){
out.println("alert(\"" + message + "\");");
}
%>
}
/*a range of options (products) based on which it decides redirection or form submission
* will lead to the new webapp*/
var productArray=["iirDefault","ilmDefault","mdmDefault"];
$(document).ready(function(){
});
/*Button event handler for the intermediate screen for product selection after login*/
$('#btnLaunchCSM').click(function(event){
event.preventDefault();
var selectedProduct=$('input[name=product_name]:checked').val();
if(jQuery.inArray(selectedProduct, productArray)!=-1)
{
e_add=$("#emailaddress").val();
p_id=$('input[name=project_id]:checked').val();
alert(e_add+", "+p_id);
<%
String e_add=request.getParameter("email_id");
String p_id=request.getParameter("project_id");
response.sendRedirect("http://abhishek:9090/abc/view/loginProxy.jsp?email_id="+e_add+"&project_id="+p_id);
%>
}
else
{
$("#launchSSO").submit();
}
});
</script>