Reputation: 17806
I would like to do an alert confirmation when user submits a form, how do I do that?
I've used:
PrintWriter out = response.getWriter();
response.setContentType("text/html");
out.println("<script type=\"text/javascript\">");
out.println("alert('form submitted!');");
out.println("</script>");
but it leaves the page blank.
how do I do the alert without refreshing the background page?
Upvotes: 1
Views: 770
Reputation: 114367
You need to use AJAX. All normal requests result in a new page being served.
btw: alert() is a bit of a blunt tool and is not considered be part of a "good user experience". You may want to have a modal dialog instead.
Upvotes: 4