javascript - why cant my html code send a request to my servlet through XMLHttpRequest! i am using the Get method and i think i have used the correct servlet url -


i not able send request jasonresult servlet.. pls me have gone wrong. have tried on both eclipse , chrome environment. here trying build dynamic chart of chart.js. needs jason file update chart.. servlet not getting request call ajax in html form.

<html>    <head>       <title>refresh</title>       <link rel="stylesheet" href="testcss.css"/>       <script           src="https://cdnjs.cloudflare.com/ajax/libs/chart.js/2.6.0/chart.js">       </script>       <script src="https://cdnjs.cloudflare.com/ajax/libs/chart.js/2.6.0/chart.min.js">       </script>    </head>    <body>       <div class="container">          <input type="date" id="startdate"></input>          <button name="button" id="button" onclick="reload()";>reload</button>          <canvas id="mychart" width="700" height="500"></canvas>          <script>             var ctx = document.getelementbyid("mychart").getcontext('2d');             var chartdata={val:null}             chartdata.val={                 type: 'bar',                 data: {                     labels: ["red", "blue", "yellow", "green", "purple", "orange"],                     datasets: [{                         label: '# of votes',                         data: [12, 19, 3, 5, 2, 3],                         backgroundcolor: [                             'rgba(255, 99, 132, 0.2)',                             'rgba(54, 162, 235, 0.2)',                             'rgba(255, 206, 86, 0.2)',                             'rgba(75, 192, 192, 0.2)',                             'rgba(153, 102, 255, 0.2)',                             'rgba(255, 159, 64, 0.2)'                         ],                         bordercolor: [                             'rgba(255,99,132,1)',                             'rgba(54, 162, 235, 1)',                             'rgba(255, 206, 86, 1)',                             'rgba(75, 192, 192, 1)',                             'rgba(153, 102, 255, 1)',                             'rgba(255, 159, 64, 1)'                         ],                         borderwidth: 1                     }]                 },                 options: {                     scales: {                         yaxes: [{                             ticks: {                                 beginatzero:true                             }                         }]                     }                 }             }              function reload(){                 alert('test');                 var xml;                 if(window.activexobject){ xml = new activexobject("microsoft.xmlhttp");                  }                 else if(window.xmlhttprequest){ xml = new xmlhttprequest(); }                   xml.open("get","http://localhost:8080/test/jasonresult?                 startdate="+document.getelementbyid('startdate').value,false);                 alert('test2');                  xml.onreadystate = function(){                     if(xml.status==200 && xml.readystate == 4){                         var jason = eval('('+xml.responsetext+')');                         alert(jason);                         chartdata.val.data.datasets[0].data= jason.values;                         mychart.update();                     }                 }                 xml.send();             }             var mychart = new chart(ctx, chartdata.val);          </script>       </div>    </body> </html> 


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -