Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(document).ready(function() {
- // AJAX Get all customers from server Call
- $.ajax({
- type: "GET",
- url: "cashpoint/customers",
- success: function(jsonData){
- var customers = eval(jsonData);
- renderCustomersTable(customers);
- }
- });
- function renderCustomersTable(customers){
- for ( var i = 0; i < customers.length; i++) {
- function appendRow(customer){
- var row = $('<tr>');
- row.append($('<td>' + customer.basarNumber + '</td>'
- + '<td>' + customer.firstname + '</td>'
- + '<td>' + customer.name + '</td>'));
- var linksCell = $('<td>');
- row.append(linksCell);
- linksCell.append(
- $('<a href="customer-edit.html?customerId='
- +customer.basarNumber +'">Edit</a>'));
- linksCell.append($('<a>',{
- id: 'removeLink:'+customer.basarNumber,
- text: 'Remove',
- href: '#',
- click: function(){
- // AJAX Delete Customer Call
- $.ajax({
- type: "DELETE",
- url: "cashpoint/deleteCustomer?basarNumber="+customer.basarNumber,
- success: function(){
- $(row).remove();
- }
- });
- }
- }));
- row.appendTo('#customerTable');
- }
- appendRow(customers[i]);
- }
- }
- $('#newCustomerButton').click(function() {
- window.location.href = 'customer-edit.html';
- });
- });
Add Comment
Please, Sign In to add comment