Advertisement
LoganYoung87

Untitled

May 31st, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 1.75 KB | None | 0 0
  1. $(".get_receipts").on("click", function () {
  2.     $("#p2").show();
  3.     var Store = $("#Store").val();
  4.     var From = $("#FromDate").val();
  5.     var To = $("#ToDate").val();
  6.  
  7.     var Invoice = { "Store": Store, "From": From, "To": To };
  8.  
  9.     $.ajax({
  10.         url: "/Invoice/GetReceipts",
  11.         data: Invoice,
  12.         dataType: 'json',
  13.         type: 'POST',
  14.         error: function () {
  15.             $("#p2").hide();
  16.             showMessage("Get Receipts", "There was a problem getting receipts for the invoice.");
  17.         },
  18.         success: function (data) {
  19.             $("#p2").hide();
  20.             /* loop through the JSON data.Receipts and add the data there as
  21.                 rows to table#data.
  22.                 Receipt properties are:
  23.                     Number,
  24.                     Date,
  25.                     Value
  26.             */
  27.             console.log(data);
  28.             data.Receipts.forEach(function () {
  29.                 $("table#data tbody").append('<tr><td class="mdl-data-table__cell--non-numeric">' + this.ReceiptNumber + ',</td><td class="mdl-data-table__cell--non-numeric">' + this.ReceiptDate + '</td><td class="mdl-data-table__cell--non-numeric">' + this.Value+ '</td></tr>');
  30.             })
  31.             $("#InvoiceTotal").append(data.InvoiceTotal);
  32.             $("#Results").show();
  33.         }
  34.     });
  35. });
  36.  
  37. /* RETURNS THE FOLLOWING (pasted from console)
  38. Object {Receipts: Array[6], InvoiceTotal: 37}
  39. InvoiceTotal
  40. :
  41. 37
  42. Receipts
  43. :
  44. Array[6]
  45. 0
  46. :
  47. Object
  48. ContentEncoding
  49. :
  50. null
  51. ContentType
  52. :
  53. null
  54. Data
  55. :
  56. Object
  57. Value
  58. :
  59. 2.6
  60. Id
  61. :
  62. 3
  63. ReceiptDate
  64. :
  65. "2015/06/08 12:00:00 AM"
  66. ReceiptNumber
  67. :
  68. "0209"
  69. __proto__
  70. :
  71. Object
  72. JsonRequestBehavior
  73. :
  74. 1
  75. MaxJsonLength
  76. :
  77. null
  78. RecursionLimit
  79. :
  80. null
  81. __proto__
  82. :
  83. Object
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement