jsp Ajax GET working POST not working -


i need refresh part of browser. hence using ajax. when use method, can see data @ server, when use post not able to. pointers please ?

-----------code searchpan.jsp-------------------------

<html>   <%   try   {           system.out.println("url " + request.getrequesturi());           system.out.println("pan " + request.getquerystring());           system.out.println("pan " + request.getparameter("pan"));   }   catch(exception e)   {           system.out.println("error happened " + e);   }           //promo_card cardobj = new promo_card();           //out.println(cardobj.getdata());   %> </html> 

----------------------------code get------------------------------------

xmlhttp=new xmlhttprequest(); xmlhttp.onreadystatechange=function() {  if(xmlhttp.readystate==0)          document.getelementbyid('status').innerhtml='uninitialized';  else if(xmlhttp.readystate==1)          document.getelementbyid('status').innerhtml='loading...';  else if(xmlhttp.readystate==2)          document.getelementbyid('status').innerhtml='loaded';  else if(xmlhttp.readystate==3)          document.getelementbyid('status').innerhtml='interactive';  else if(xmlhttp.readystate == 4 && xmlhttp.readystate == 200)          document.getelementbyid("div1").innerhtml = xmlhttp.responsetext; } if(xmlhttp) {   var querystring = 'searchpan.jsp?pan=' + document.getelementbyid('pan_number').value;   xmlhttp.open("get", querystring, true);   xmlhttp.send(); } 

when use method, below output

url /cardsit/promo/card/searchpan.jsp pan pan=123456789 pan 123456789 

when use post, unable, .. below. url /cardsit/promo/card/searchpan.jsp pan null pan null 

----------------------code post----------------------------

xmlhttp.open("post", "searchpan.jsp", true);   var querystring = 'searchpan.jsp';   querystring = 'pan=' + document.getelementbyid('pan_number').value;   alert(querystring);   xmlhttp.send(querystring); 

try below code

xmlhttp.open("post", "searchpan.jsp", true); xmlhttp.setrequestheader("content-type","application/x-www-form-urlencoded"); var querystring = 'pan=' + document.getelementbyid('pan_number').value; xmlhttp.send(querystring); 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -