[英]how to redirect from servlet to jsp using ajax instead of request dispatcher
<button type="submit" name ="ajax1" id="ajax1" onClick="return SaveAdminMessage();"><b>SEND</b></button>
while clicking above button to save the data that we enter and refresh the list that display the entered data. 同时点击上方按钮以保存我们输入的数据并刷新显示输入数据的列表。
function SaveAdminMessage() {
alert("Please enter Your Message..!");
$.ajax({
type: 'post',
url: 'adminchatServlet',
success: alert("success ajax");
});
}
You can do one thing after successful call of ajax that you are making , you can right below code 成功调用ajax之后,您可以做一件事,可以在代码下面
if (success) {
var pageToRedirectUrl = "success.jsp"; //URL of your page
window.location.href = pageToRedirectUrl ;
}
Above code will allow you to redirect to another page after successfully executing ajax call. 上面的代码将允许您在成功执行ajax调用后重定向到另一个页面。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.