ajax parameter to send correctly a variable to a specified url
- by kawtousse
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