Home Onclick event of a certain page, perform POST action of other page

# Onclick event of a certain page, perform POST action of other page

jitendra
1#
jitendra Published in 2010-11-15 06:40:40Z
 Let me explain my problem with a scenario: I have webpages "A.jsp" and "B.jsp". "B.jsp" is a page with a form that requires input field, 'username' and on submission displays a certain page "C.jsp" with user-specific information. "A.jsp" has table with an element that would correspond to 'username' on "B.jsp". Onclick of a certain 'username' on "A.jsp", I want to be redirected to "C.jsp" with clicked username specific information. How do I get it done? I am using MVC framework. Only A.jsp and B.jsp are tied to controller, C.jsp is only a View. But, I believe that is less of an issue, since this seem to be more of a javascript question. Using prototype javascript framework, I have tried the following: redirectToC=function(pageurl){ var username=document.getElementById("user1").value; url=pageurl; //I am using B.jsp as Pageurl \$j.ajax({ type: 'POST', url: url, data: "username="+username, success: function(request){ window.location=request; } }); }
 Does C.jsp support only POST - or does it support GET requests as well? If it does, in the onClick of the 'username' link, set the location of the browser (i think document.location) to the URL of C.jsp with the username as a GET parameter. Since you are generating the A.jsp page dynamically, this URL can be embedded into the page at generation time If it does not, a bad hack i can think of is to implement the the table element with the username, as a hidden form element which is submitted via javascript when clicked - 'form'.submit()
 
 ..........   ..........