I'm posting data to Servlet by using ajax. And I don't know how to GET result from Servlet. Please help me to solve this problem. I want to get Result from Servlet. If its success redirect to Success page, if its Failed, redirect to failed page.
Ajax getting response "success" but not redirecting to another page. this is response
This is what I have done till now:
<script>
$(document).ready(function() {
setInterval("ajaxd()",3000);
});
function ajaxd() {
$.ajax({
url:'/Query.cfm',
data:{amount:'<%=amount%>', No:'<%=No%>', eno:'<%=No%>', fno:'<%=fno%>', sign:'<%=sign%>'},
type:'get',
cache:false,
success:function(data){
if (data == 'success') {
var u = '/notic/succ.jsp?No=<%=No%>&amount=<%=amount%>';
alert(u);
window.location.href = u;
}else if(data == 'failed'){
window.location.href = '"/notic/failed.jsp?No="<%=No%>"&amount="<%=amount%>';
}
},
}
);
}
</script>
This is my Servlet's response: Result: can be "success" or "failed"
response.setContentType("text/plain");
response.getWriter().println(Result);