!DOCTYPE html html head link rel="stylesheet" href="demo/claro.css" scriptdojoConfig = {parseOnLoad: true}/script script src='dojo/dojo.js'/script script require(["dojo/dom-form", "dojo/dom", "dojo/on", "dojo/json", "dojo/request/xhr","dojo
<!DOCTYPE html> <html > <head> <link rel="stylesheet" href="demo/claro.css"> <script>dojoConfig = {parseOnLoad: true}</script> <script src='dojo/dojo.js'></script> <script> require(["dojo/dom-form", "dojo/dom", "dojo/on", "dojo/json", "dojo/request/xhr","dojo/domReady!"], function(domForm, dom, on, JSON,xhr){ var sform = domForm.toObject("myform"); var fdata = JSON.stringify(sform); on(dom.byId("myform"), "submit", function(event){ alert(domForm.toJson("myform")); // Stop the submit event since we want to control form submission. event.stopPropagation(); event.preventDefault(); xhr("http://localhost:8080/Helloweb24/CVSServlet", { method: "post", query: domForm.toObject("myform"), handleAs: "text" }) .then( function(data){ dojo.byId("response").innerHTML = "Form posted correctly.result is: "+JSON.stringify(data); }, function(err){ dojo.byId("response").innerHTML = "Form posted error."+err; }); }); }); </script> </head> <body class="claro"> <b>Simple Form:</b> <br> <blockquote> <form action="CVSServlet" id="myform" name="myform" method="post"> method: <input type="text" name="method" value="xhrpost"></input> Text: <input type="text" name="formInput" value="Some text"></input><br><br> Checkbox: <input type="checkbox" name="checkboxInput"></input><br><br> <button type="submit" id="submitButton">Send it!</button> </form> </blockquote> <br> <b>Result</b> <div id="response"></div> </body> </html>