Guest User

Untitled

a guest
Jul 17th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. $(document).ready(function() {
  2.  
  3. // AJAX Get all customers from server Call
  4. $.ajax({
  5. type: "GET",
  6. url: "cashpoint/customers",
  7. success: function(jsonData){
  8. var customers = eval(jsonData);
  9. renderCustomersTable(customers);
  10. }
  11. });
  12.  
  13. function renderCustomersTable(customers){
  14. for ( var i = 0; i < customers.length; i++) {
  15. function appendRow(customer){
  16. var row = $('<tr>');
  17.  
  18. row.append($('<td>' + customer.basarNumber + '</td>'
  19. + '<td>' + customer.firstname + '</td>'
  20. + '<td>' + customer.name + '</td>'));
  21.  
  22. var linksCell = $('<td>');
  23. row.append(linksCell);
  24.  
  25. linksCell.append(
  26. $('<a href="customer-edit.html?customerId='
  27. +customer.basarNumber +'">Edit</a>'));
  28.  
  29. linksCell.append($('<a>',{
  30. id: 'removeLink:'+customer.basarNumber,
  31. text: 'Remove',
  32. href: '#',
  33. click: function(){
  34. // AJAX Delete Customer Call
  35. $.ajax({
  36. type: "DELETE",
  37. url: "cashpoint/deleteCustomer?basarNumber="+customer.basarNumber,
  38. success: function(){
  39. $(row).remove();
  40. }
  41. });
  42. }
  43. }));
  44.  
  45. row.appendTo('#customerTable');
  46. }
  47. appendRow(customers[i]);
  48. }
  49. }
  50.  
  51. $('#newCustomerButton').click(function() {
  52. window.location.href = 'customer-edit.html';
  53. });
  54.  
  55. });
Add Comment
Please, Sign In to add comment