我正在对这样的jsp页面进行ajax调用:
$(document).ready(function () {
$('#photo').photobooth().on("image", function (event, dataUrl) {
alert(dataUrl);
//alert($('#mygroupuserid'));
//alert(document.Clickpictures.OwnerId.value);
//alert(imgdata);
$.ajax({
url: 'uploadwebcamimage.jsp',
type: "POST",
data: {
encodeimg: dataUrl,
OwnerId: document.Clickpictures.OwnerId.value,
OwnerPhone: document.Clickpictures.OwnerPhone.value,
mobilepass: document.Clickpictures.mobilepass.value,
emailpass: document.Clickpictures.emailpass.value,
mypassword: document.Clickpictures.mypassword.value,
mygroupuserid: document.Clickpictures.mygroupuserid.value
},
error : function(){
alert('Error');
},
success: function(msg){
alert(msg);
}
});
$("#gallery").show().html('<img src="' + dataUrl + '" >');
});
});
现在在jsp页面中,我必须根据这样的标志值做出决定:
if(flag==true){
out.println("<script>alert('Face Successfully Detected and Password has been sent');document.location='Main.jsp'</script>");
}
else if(flag==false){
out.println("<script>alert('Sorry,Face Cant Be Detected.Try Again');</script>");
}%>
如何实现这一目标。由于此警报框没有立即打印。请帮助
答案 0 :(得分:0)
您需要阅读参数值并根据您的期望进行检查:
String ownerId = request.getParameter("OwnerId");
if("target".equals(ownerId))
{
out.println("<script>....");
}
要在客户端的响应中收到Javascript后运行,您必须使用eval()
。你需要在你的第一个JS脚本中修复丢失的半冒号。