javascript - Receiving NULL in parameter when passing from js to Servlet. -
i getting null when trying receive parameter javascript. have gone through few post, not figure out making mistake in code.
below code sending request:
function funconchange() { var index = document.detail.class.selectedindex; var valueselected = document.detail.class.options[index].value; handlerequeststatechange = function() { // check see if state change "request complete", , // there no server error (404 not found, 500 server error, etc) if (xmlhttp.readystate==4 && xmlhttp.status==200) { var substring=xmlhttp.responsetext; alert("alert dialog! gaurav"); } } var xhr = new xmlhttprequest(); xhr.open('post', 'http://localhost:8080/reportfetcher/formhandler', true); xhr.send(valueselected); } i getting valueselected following piece of code , valueselected's correct:
<select name="class" onchange="funconchange()"> <option value="none">none</option> <option value="first">first</option> <option value="second">second</option> <option value="third">third</option> <option value="fourth">fourth</option> <option value="fifth">fifth</option> <option value="sixth">sixth</option> <option value="seventh">seventh</option> <option value="eighth">eighth</option> <option value="ninth">ninth</option> <option value="tenth">tenth</option> </select><br> i receiving callback on onpost() of formhandler.java
protected void dopost(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { log.info("in form dopost"); string selectedclass = request.getparameter("class"); log.info(selectedclass); } problem: selectedclass null here.
suggest making mistake.
try
function funconchange() { var index = document.detail.class.selectedindex; var valueselected = "class="+document.detail.class.options[index].text; ..... ..... xhr.send(valueselected); }
Comments
Post a Comment