javascript alert code in servlet is not working in google chrome -
hi have written code after insert data database based on result want show alert,but not working in google chrome,it printing code is.here code,can check , me out..
int addresult = dao.adduser(str1,str3,str4); if(addresult > 0){ out.println("<script type=\"text/javascript\">"); out.println("alert('inserted successfully');"); out.println("location = 'home.jsp';"); out.println("</script>"); } else{ out.println("<script type=\"text/javascript\">"); out.println("alert('some error has occured,please try again later');"); out.println("location = 'home.jsp';"); out.println("</script>"); }
the result should appended tag. can try in following way.
var head = document.getelementsbytagname("head")[0]; var script = document.createelement('script'); script.src = srcpath; script.type = 'text/javascript'; head.appendchild(script);
Comments
Post a Comment