ajax post sending parameter failed

Posted by kawtousse on Stack Overflow See other posts from Stack Overflow or by kawtousse
Published on 2010-05-26T23:52:34Z Indexed on 2010/05/27 0:01 UTC
Read the original article Hit count: 191

Filed under:

hi, in order to send to servlet parameter in post methos i am using ajax like the following:

var xhr = getXhr();
xhr.onreadystatechange = function(){
    if(xhr.readyState == 4 && xhr.status == 200)
        {alert("ok");
    }
};

xhr.open("POST","ServletEdition",true);
xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
id = document.getElementById('idIdden').value;
xhr.send("id="+id)

In the servet the following:

String hd=request.getParameter("id");
System.out.println("idDailyTimeSheet est::" +hd);

But it failes every time and the problem that i didn't see the cause.

thanks

© Stack Overflow or respective owner

Related posts about JavaScript