javascript - Getting Ajax error when invoking Servlet -


i'm brand new ajax , servlet. i'm trying call servlet ajax function.its not working. here javascript file: ajaxs.js

var xmlhttp;  function ajaxfunction() {    xmlhttp=getxmlhttpobject();    if (xmlhttp==null)   {      alert ("your browser not support ajax http");      return;   }     var numberlist = document.getelementbyid("inputstring");    var kth = document.getelementbyid("nthhighest");     xmlhttp.open('post','/hellohalozen/highestnumber',true);    xmlhttp.onreadystatechange  = handleserverresponse;    xmlhttp.setrequestheader('content-type', 'application/x-www-form-urlencoded');    xmlhttp.send("inputstring=" + numberlist.value + "&nthhighest="+kth.value); }  function getxmlhttpobject() {   if (window.xmlhttprequest)    {      return new xmlhttprequest();     }   if (window.activexobject)    {      return new activexobject("microsoft.xmlhttp");    }  return null;   }  function handleserverresponse() {    if (xmlhttp.readystate==4 && xmlhttp.status==200) {        document.getelementbyid("result").innerhtml=xmlhttp.responsetext;    }    else {      alert("error during ajax call. please try again");    }  } 

i'm trying invoke highestnumber servlet. can access url: http://localhost:8080/hellohalozen/highestnumber. now, every time call ajaxfunction(), hits alert("error during ajax call. please try again"); , xmlhttp.readystate= 1.

i can't figure out whats going wrong... can u pls me identify i'm doing wrong here...

thanks in advance


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -