ambikanair
ambikanair

Reputation: 4590

Second JSP page is not getting loaded after a AJAX POST request

I have the below code in page1.jsp.

$.ajax({
            type: "post",
            url: "page2.jsp",
            data: newdata,
            success:function(msg){
                return msg; 
            }                                                        
        })  

Even after POST request, the page remains in page1.jsp and doesn't navigate to page2.jsp. I am seeing statusCode as "200 OK" when I did inspect element. How should I pass the control to page2.jsp if the AJAX call is success. If I am missing some code please correct me.

Upvotes: 0

Views: 181

Answers (1)

thllbrg
thllbrg

Reputation: 2007

If you want to navigate to the page you made the post to if the post success, you need to navigate in the success function

$.ajax({
    type: "post",
    url: "page2.jsp",
    data: newdata,
    success:function(msg) {
        window.location = "page2.jsp";
    }
})  

Upvotes: 1

Related Questions