java - how to get parameter values of json array in servlet that is sent from ajax -
i want send html table data using ajax servlet can save mysql database, therefore question is, prepared html data array , sent servlet ok, problem while in servlet how can each value save database. code.
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> script type="text/javascript"> $(document).ready(function () { //launch code after whole dom loaded $("form").submit(function (event) { // function process submitted table var a={}; var tabledata = []; // store rows' data array $("#admintable") // select table id .find(".tablerow") // select rows class .has(":checked") // select rows checked checkboxes .each(function () { // each selected row extract data var tablerow = {}; var jrow = $(this); tablerow.customerid = jrow.find('td.customerid').text(); tablerow.customertype = jrow.find('td.customertype').text(); tablerow.customerkwh = jrow.find('td.customerkwh').text(); tablerow.costomerkwd = jrow.find('input.name1').val(); tabledata.push(tablerow); //alert(tablerow.costomerkwd); }); $.post( "generatekwd", /*url of consuming servlet*/ {tabledata: tabledata}, /*data*/ function () { alert("success!"); }, /*function execute in case of success*/ "json" /* data type */ ); event.preventdefault(); //prevent sending form browser } ); });
Comments
Post a Comment