ajax parameter to send correctly a variable to a specified url

Posted by kawtousse on Stack Overflow See other posts from Stack Overflow or by kawtousse
Published on 2010-03-23T13:31:26Z Indexed on 2010/03/23 13:33 UTC
Read the original article Hit count: 272

Filed under:
|
|

I am trying to send data to a servlet from a js file but the servlet never received the parameter. so this is what I have: function showProject(prj) { xmlhttp=GetXmlHttpObject(); if (xmlhttp==null) { alert ("Browser does not support HTTP Request"); return; }

var url="ServletxmlGenerator"; idprj = prj.options[prj.selectedIndex].value; //alert(idprj); url=url+"?idprj="+idprj; xmlhttp.onreadystatechange=stateChanged; xmlhttp.open("GET",url,true); xmlhttp.send(null); }

and to capture th request it is with: public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

String projectcode=request.getParameter("idprj");
System.out.println("++++projectCode:=" +projectcode);

the output is like: ++++projectCode:=null Can any one explain it to me it seems to be correct but i didnot find the error.Thinks

© Stack Overflow or respective owner

Related posts about AJAX

Related posts about j2ee