UNPKG

nic_training

Version:

Sample demos for training on nodejs

72 lines (71 loc) 1.68 kB
<!DOCTYPE html> <html> <head> <title>Using REST Service</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script type="text/javascript"> var url ='http://10.163.14.66:1234' function viewRecords() { $("#tblRecs").find("tr:gt(0)").remove(); $.get(url, function(data) { var collection = JSON.parse(data); $.each(collection, function(index, val) { var row = '<tr><td>'; row += val.empID +'</td><td>'; row += val.empName +'</td><td>' row +=val.empAddress +'</td></tr>' $('#tblRecs').append(row); }); }); } $(document).ready(function() { //$("div").hide(1000) viewRecords() $("a").click(function() { // $("#divAdd").show(1000) $("button").click(function () { var data ={}; data.empID = $("#txtID").val(); data.empName = $("#txtName").val(); data.empAddress = $("#txtAddress").val(); $.post(url, data); }) }) }); </script> </head> <body> <h1>Employee Monitoring System</h1> <a href="#">Add New</a> <table> <tr style="vertical-align: top;"> <td> <table id="tblRecs" border="1"> <tr> <th>EmpID</th> <th>EmpName</th> <th>EmpAddress</th> </tr> </table> </td> <td> <div id="divAdd"> <h1>Add new Employee</h1> <p>Enter the EmpID: <input type="text" id="txtID"> </p> <p>Enter the EmpName: <input type="text" id="txtName"> </p> <p>Enter the EmpAddress: <input type="text" id="txtAddress"> </p> <p> <button>Add Record</button> </p> </div> </td> </tr> </table> </body> </html>