【问题标题】:getting error data[i].order is not a function获取错误数据 [i].order 不是函数
【发布时间】:2020-10-21 18:11:24
【问题描述】:

我有任务要完成。即我需要根据搜索调用 JSON 对象,并且应该在引导表中获得结果。我尝试以不同的方式修复,但没有找到确切的解决方法,因为我对 JS 很陌生。我在许多研究的帮助下编写代码。

但是当我运行代码时。在控制台中我收到类似的错误

script.js:1470 Uncaught TypeError: data[i].order is not a function
    at getResult (script.js:1470)
    at HTMLInputElement.onClick (script.js:1480)
    at HTMLInputElement.dispatch (jquery.min.js:2)
    at HTMLInputElement.v.handle (jquery.min.js:2)

我正在尝试修复它,但没有发生。有人可以帮帮我吗。我从前两天开始尝试,但每次我修复一个错误时,都会出现另一个错误。

var data = [{
    "eventInfo": {
      "context": {
        "siteTimezone": "Asia/Brunei",
        "entityPk": "8802089762861",
        "entityClass": "de.hybris.platform.core.model.order.OrderModel",
        "com.amway.core.events.model.AmwayEventQueueEntryModel": "8805563195834"
      },
      "isoCountryCode": "BN",
      "eventType": "ORDER_CONFIRMED",
      "entityType": "salesorder",
      "sourceTimestamp": "2020-06-25T14:05:56.683+08:00",
      "sourceApplication": "HYBRIS",
      "affiliateCode": "100",
      "entityId": "7100029639",
      "sourceEventId": "4521231e-c347-459b-8d46-43cd2010c8c1",
      "accountId": "8055817",
      "sourceHost": "ip-10-127-165-135.ap-southeast-1.compute.internal"
    },
    "entity": {
      "lynxIsPCP": false,
      "paymentRequired": true,
      "bonusTransactionRequired": true,
      "addresses": [{
          "telephoneNumber": "03-7946 2800",
          "isoCountryCode": "BN",
          "line3": "Bandar Seri Begawan",
          "cityName": "Brunei",
          "line2": "Kampung Kiulap",
          "line1": "6 & 7, Block A, Kompleks Shakirin",
          "careOfName": "",
          "state": "BR",
          "emailAddress": "vhwzezgj@rzrcy.bmh",
          "postalCode": "BE1518",
          "id": "8804188225559"
        },
        {
          "telephoneNumber": "5494492",
          "isoCountryCode": "BN",
          "line3": "GADONG",
          "line4": "8171571",
          "cityName": "BDR SERI BEGAWAN",
          "line2": "KAMPONG RIMBA",
          "line1": "5 SIMPANG 12-32",
          "careOfName": "",
          "state": "BR",
          "emailAddress": "vhwzezgj@rzrcy.bmh",
          "postalCode": "BE3119",
          "id": "8802223521815"
        },
        {
          "telephoneNumber": "5494492",
          "isoCountryCode": "BN",
          "line3": "GADONG",
          "line4": "8171571",
          "cityName": "BDR SERI BEGAWAN",
          "line2": "KAMPONG RIMBA",
          "line1": "5 SIMPANG 12-32",
          "careOfName": "",
          "state": "BR",
          "emailAddress": "vhwzezgj@rzrcy.bmh",
          "postalCode": "BE3119",
          "id": "8802223521815"
        },
        {
          "telephoneNumber": "03-7946 2800",
          "isoCountryCode": "BN",
          "line3": "Bandar Seri Begawan",
          "cityName": "Brunei",
          "line2": "Kampung Kiulap",
          "line1": "6 & 7, Block A, Kompleks Shakirin",
          "careOfName": "",
          "state": "BR",
          "emailAddress": "myhelpdesk@Amway.com",
          "postalCode": "BE1518",
          "id": "8800157073431"
        }
      ],
      "totalOrderValue": 147.5,
      "lynxPaymentChangePaid": 0.0,
      "lynxIsRepair": false,
      "adjustments": [],
      "requestedDeliveryServiceLevel": "walkin",
      "lynxTenure": 0,
      "saleCountryCode": "BN",
      "orderDateTime": "2020-06-25T14:05:56.328+08:00",
      "invoiceSalesAccount": {
        "lynxBusinessStyle": "ROHANA LATIP & WAN ROSLAN",
        "accountId": "8055817",
        "lynxPinLevel": "330",
        "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
        "affiliateCode": "100"
      },
      "userAgent": "Suresh Mathiarasu",
      "orderStatus": "CONFIRMED",
      "isoCurrencyCode": "BND",
      "fees": [{
        "feeCode": "walkin",
        "feeTaxTotalAmount": 0.0,
        "lynxRefunded": false,
        "feeAmount": 0.0,
        "feeTaxDetails": [{
          "taxAmount": 0.0,
          "taxCode": "BN_NO_SCOPE_VAT_SALES"
        }]
      }],
      "bonusPeriod": "202006",
      "orderingPartyId": "40986385",
      "lynxPayerPartyId": "40986385",
      "salesChannelCode": "Point of Sale",
      "lynxIsEpp": false,
      "lynxPayerPartyName": "ROHANA BINTI HJ LATIP",
      "lynxDemandLocationName": "BN",
      "lynxDeliveryType": "pis",
      "paymentSalesAccount": {
        "lynxBusinessStyle": "ROHANA LATIP & WAN ROSLAN",
        "accountId": "8055817",
        "lynxPinLevel": "330",
        "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
        "affiliateCode": "100"
      },
      "orderPriceList": "AmwayDefaultABOPriceGroup",
      "lynxVolumePartyId": "40986385",
      "lynxHasSopEntries": false,
      "orderLines": [{
        "linePrice": 147.5,
        "itemType": "AmwayVariantProduct",
        "itemBV": 29.5,
        "lynxBirTaxPerUnit": 0.0,
        "lynxInvoiceNumber": "130099000",
        "lynxLineAdjustedPV": 0.0,
        "shippedQuantity": 0,
        "lineStatus": "OPEN",
        "lynxProductSerialNumber": [],
        "lineUnitOfMeasure": "EA",
        "allocatedQuantity": 5,
        "linePVAmount": 95.0,
        "lynxBmCode": [],
        "lastUpdateDate": "2020-06-25T14:05:56.469+08:00",
        "lynxBillingAddressReference": "8802223521815",
        "cancelledQuantity": 0,
        "lynxBaseItemId": "115383D",
        "demandLocation": "T45",
        "backorderedQuantity": 0,
        "taxNotRequired": false,
        "pickupAddressReference": "8804188225559",
        "unallocatedQuantity": 0,
        "pendingQuantity": 5,
        "itemABOPrice": 29.5,
        "lineTaxTotalAmount": 0.0,
        "lynxIsSopLine": false,
        "lynxWasBackorder": false,
        "itemSuggestedRetailPrice": 37.0,
        "lineTotalValue": 147.5,
        "baseItemId": "115383D",
        "lynxMasterCode": [],
        "itemDescription": "ARTISTRY SIGNATURE COLOR Lipstick - Daring Red (06) (3.8g)",
        "lineTaxDetails": [{
          "taxAmount": 0.0,
          "taxCode": "BN_NO_SCOPE_VAT_SALES"
        }],
        "shipAddressReference": "8804188225559",
        "lynxPickupAddressName": "BN",
        "lynxIsSopEntry": false,
        "lynxBirAcknowledgementResetCounter": "1",
        "lynxLineAdjustedBV": 0.0,
        "orderedQuantity": 5,
        "itemListPrice": 29.5,
        "fulfillmentType": "walkin",
        "returnedQuantity": 0,
        "orderLineId": 0,
        "itemPV": 19.0,
        "lineBVAmount": 147.5
      }],
      "lynxFulfillmentAddressReference": "8800157073431",
      "cashierBatchId": "amwaybrunei-AM-BN-BN-T45-MY020394-1593058911313",
      "lynxOrderingPartyName": "ROHANA BINTI HJ LATIP",
      "totalBVAmount": 147.5,
      "lynxVolumeTransactions": [],
      "volumeSalesAccount": {
        "lynxBusinessStyle": "ROHANA LATIP & WAN ROSLAN",
        "accountId": "8055817",
        "lynxPinLevel": "330",
        "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
        "affiliateCode": "100"
      },
      "taxDetails": [{
        "taxAmount": 0.0,
        "taxCode": "BN_NO_SCOPE_VAT_SALES"
      }],
      "lynxUserType": "AmwayBusinessNature_1",
      "lynxPaymentTenderedAmount": 147.5,
      "lynxVolumePartyName": "ROHANA BINTI HJ LATIP",
      "lynxOrderCreatedBy": "MY020394",
      "lynxOms": "Hybris",
      "orderForSalesAccount": {
        "lynxBusinessStyle": "ROHANA LATIP & WAN ROSLAN",
        "accountId": "8055817",
        "lynxPinLevel": "330",
        "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
        "affiliateCode": "100"
      },
      "lynxPaymentInstalmentType": "PIF",
      "lynxMemberPoints": 0.0,
      "lynxContactPhone": "5494492",
      "totalPVAmount": 95.0,
      "inventoryTransactionRequired": true,
      "lynxIsEventBooking": false,
      "lynxBirCashierId": "MY020394",
      "refunds": [],
      "invoiceWithConsignmentRequired": false,
      "orderPeriod": "202006",
      "orderingSalesAccount": {
        "lynxBusinessStyle": "ROHANA LATIP & WAN ROSLAN",
        "accountId": "8055817",
        "lynxPinLevel": "330",
        "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
        "affiliateCode": "100"
      },
      "lynxContactEmailId": "vhwzezgj@rzrcy.bmh",
      "amwaySalesEntity": "780",
      "paymentStatus": "PAID",
      "storefront": "amwaybrunei",
      "lynxPaymentType": "PIF",
      "salesOrderId": "7100029639",
      "lynxOrderCategory": "selfOrder",
      "payments": [{
        "verificationDate": "2020-06-25T14:05:54.453+08:00",
        "lynxIsConnectedFlow": false,
        "paymentLocation": "T45",
        "lynxPaymentProcessedBy": "8055817",
        "paymentStatus": "ACCEPTED",
        "terminalId": "MY020394",
        "paymentReferenceId": "TXN-1593065154321",
        "payerSalesAccount": {
          "accountId": "8055817",
          "lynxPinLevel": "330",
          "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
          "affiliateCode": "100"
        },
        "paymentDate": "2020-06-25T14:05:54.456+08:00",
        "isoCurrencyCode": "BND",
        "lynxPaymentInformation": "",
        "paymentId": "831122002_4e7c1945-b49d-4c86-a0b8-a05b0cb805fa",
        "paymentValue": 147.5,
        "paymentMethod": "cash",
        "merchantId": "amway"
      }],
      "shipToSalesAccount": {
        "lynxBusinessStyle": "ROHANA LATIP & WAN ROSLAN",
        "accountId": "8055817",
        "lynxPinLevel": "330",
        "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
        "affiliateCode": "100"
      },
      "totalABORetailProfit": 0.0,
      "totalTaxAmount": 0.0,
      "lynxOrderType": "NORMAL_ORDER",
      "lynxComments": []
    }
  },
  {
    "eventInfo": {
      "context": {
        "siteTimezone": "Asia/Brunei",
        "entityPk": "8802089762861",
        "entityClass": "de.hybris.platform.core.model.order.OrderModel",
        "com.amway.core.events.model.AmwayEventQueueEntryModel": "8805597503930"
      },
      "isoCountryCode": "BN",
      "eventType": "LYNX_ORDER_UPDATE",
      "entityType": "salesorder",
      "sourceTimestamp": "2020-06-25T14:05:57.250+08:00",
      "sourceApplication": "HYBRIS",
      "affiliateCode": "100",
      "entityId": "7100029639",
      "sourceEventId": "8ab538d6-e525-4c8d-b1cf-411d562715f8",
      "accountId": "8055817",
      "sourceHost": "ip-10-127-165-86.ap-southeast-1.compute.internal"
    },
    "entity": {
      "lynxIsPCP": false,
      "paymentRequired": true,
      "bonusTransactionRequired": true,
      "addresses": [{
          "telephoneNumber": "03-7946 2800",
          "isoCountryCode": "BN",
          "line3": "Bandar Seri Begawan",
          "cityName": "Brunei",
          "line2": "Kampung Kiulap",
          "line1": "6 & 7, Block A, Kompleks Shakirin",
          "careOfName": "",
          "state": "BR",
          "emailAddress": "vhwzezgj@rzrcy.bmh",
          "postalCode": "BE1518",
          "id": "8804188225559"
        },
        {
          "telephoneNumber": "5494492",
          "isoCountryCode": "BN",
          "line3": "GADONG",
          "line4": "8171571",
          "cityName": "BDR SERI BEGAWAN",
          "line2": "KAMPONG RIMBA",
          "line1": "5 SIMPANG 12-32",
          "careOfName": "",
          "state": "BR",
          "emailAddress": "vhwzezgj@rzrcy.bmh",
          "postalCode": "BE3119",
          "id": "8802223521815"
        },
        {
          "telephoneNumber": "5494492",
          "isoCountryCode": "BN",
          "line3": "GADONG",
          "line4": "8171571",
          "cityName": "BDR SERI BEGAWAN",
          "line2": "KAMPONG RIMBA",
          "line1": "5 SIMPANG 12-32",
          "careOfName": "",
          "state": "BR",
          "emailAddress": "vhwzezgj@rzrcy.bmh",
          "postalCode": "BE3119",
          "id": "8802223521815"
        },
        {
          "telephoneNumber": "03-7946 2800",
          "isoCountryCode": "BN",
          "line3": "Bandar Seri Begawan",
          "cityName": "Brunei",
          "line2": "Kampung Kiulap",
          "line1": "6 & 7, Block A, Kompleks Shakirin",
          "careOfName": "",
          "state": "BR",
          "emailAddress": "myhelpdesk@Amway.com",
          "postalCode": "BE1518",
          "id": "8800157073431"
        }
      ],
      "totalOrderValue": 147.5,
      "lynxPaymentChangePaid": 0.0,
      "lynxIsRepair": false,
      "adjustments": [],
      "requestedDeliveryServiceLevel": "walkin",
      "lynxTenure": 0,
      "saleCountryCode": "BN",
      "orderDateTime": "2020-06-25T14:05:56.328+08:00",
      "invoiceSalesAccount": {
        "lynxBusinessStyle": "ROHANA LATIP & WAN ROSLAN",
        "accountId": "8055817",
        "lynxPinLevel": "330",
        "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
        "affiliateCode": "100"
      },
      "userAgent": "Suresh Mathiarasu",
      "orderStatus": "PICKUP_COMPLETE",
      "isoCurrencyCode": "BND",
      "fees": [{
        "feeCode": "walkin",
        "feeTaxTotalAmount": 0.0,
        "lynxRefunded": false,
        "feeAmount": 0.0,
        "feeTaxDetails": [{
          "taxAmount": 0.0,
          "taxCode": "BN_NO_SCOPE_VAT_SALES"
        }]
      }],
      "bonusPeriod": "202006",
      "orderingPartyId": "40986385",
      "lynxPayerPartyId": "40986385",
      "salesChannelCode": "Point of Sale",
      "lynxIsEpp": false,
      "lynxPayerPartyName": "ROHANA BINTI HJ LATIP",
      "lynxDemandLocationName": "BN",
      "lynxDeliveryType": "pis",
      "paymentSalesAccount": {
        "lynxBusinessStyle": "ROHANA LATIP & WAN ROSLAN",
        "accountId": "8055817",
        "lynxPinLevel": "330",
        "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
        "affiliateCode": "100"
      },
      "orderPriceList": "AmwayDefaultABOPriceGroup",
      "lynxVolumePartyId": "40986385",
      "lynxHasSopEntries": false,
      "orderLines": [{
        "linePrice": 147.5,
        "itemType": "AmwayVariantProduct",
        "itemBV": 29.5,
        "lynxBmCode": [],
        "lynxInvoiceNumber": "130099000",
        "lynxLineAdjustedPV": 0.0,
        "shippedQuantity": 5,
        "lineStatus": "OPEN",
        "lynxProductSerialNumber": [],
        "lineUnitOfMeasure": "EA",
        "allocatedQuantity": 5,
        "linePVAmount": 95.0,
        "fulfillments": [{
          "fulfillmentLocation": "T45",
          "fulfilledItemRevision": "",
          "fulfilledSKU": "115383D",
          "uniqueFulfillmentID": "100000002118",
          "fulfilledBaseItemId": "115383D",
          "fulfilledDate": "2020-06-25T14:05:57.167+08:00",
          "fulfilledItemLot": "",
          "fulfilledQuantity": 5
        }],
        "actualShipDate": "2020-06-25T14:05:57.167+08:00",
        "lastUpdateDate": "2020-06-25T14:05:56.985+08:00",
        "lynxBillingAddressReference": "8802223521815",
        "cancelledQuantity": 0,
        "lynxBaseItemId": "115383D",
        "demandLocation": "T45",
        "backorderedQuantity": 0,
        "taxNotRequired": false,
        "lynxLineFulfillmentStatus": "SHIPPED",
        "lynxBirTaxPerUnit": 0.0,
        "pickupAddressReference": "8804188225559",
        "unallocatedQuantity": 0,
        "pendingQuantity": 0,
        "itemABOPrice": 29.5,
        "lineTaxTotalAmount": 0.0,
        "lynxIsSopLine": false,
        "lynxWasBackorder": false,
        "itemSuggestedRetailPrice": 37.0,
        "lineTotalValue": 147.5,
        "baseItemId": "115383D",
        "lynxMasterCode": [],
        "itemDescription": "ARTISTRY SIGNATURE COLOR Lipstick - Daring Red (06) (3.8g)",
        "lineTaxDetails": [{
          "taxAmount": 0.0,
          "taxCode": "BN_NO_SCOPE_VAT_SALES"
        }],
        "shipAddressReference": "8804188225559",
        "lynxPickupAddressName": "BN",
        "lynxIsSopEntry": false,
        "lynxBirAcknowledgementResetCounter": "1",
        "lynxLineAdjustedBV": 0.0,
        "orderedQuantity": 5,
        "itemListPrice": 29.5,
        "fulfillmentType": "walkin",
        "returnedQuantity": 0,
        "actualDeliveryDate": "2020-06-25T14:05:57.167+08:00",
        "orderLineId": 0,
        "itemPV": 19.0,
        "lineBVAmount": 147.5
      }],
      "lynxFulfillmentAddressReference": "8800157073431",
      "cashierBatchId": "amwaybrunei-AM-BN-BN-T45-MY020394-1593058911313",
      "lynxOrderingPartyName": "ROHANA BINTI HJ LATIP",
      "totalBVAmount": 147.5,
      "lynxVolumeTransactions": [{
        "lynxInterfaceType": "ORDERS",
        "lynxInterfaceAttribute": "positive",
        "lynxPointValue": 95.0,
        "lynxTransactionTime": "2020-06-25T14:05:56.981+08:00",
        "lynxStatus": "CREATED",
        "lynxTransactionType": "ORDER",
        "lynxBonusPeriod": "202006",
        "lynxBusinessValue": 147.5
      }],
      "volumeSalesAccount": {
        "lynxBusinessStyle": "ROHANA LATIP & WAN ROSLAN",
        "accountId": "8055817",
        "lynxPinLevel": "330",
        "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
        "affiliateCode": "100"
      },
      "taxDetails": [{
        "taxAmount": 0.0,
        "taxCode": "BN_NO_SCOPE_VAT_SALES"
      }],
      "lynxUserType": "AmwayBusinessNature_1",
      "lynxPaymentTenderedAmount": 147.5,
      "lynxVolumePartyName": "ROHANA BINTI HJ LATIP",
      "lynxOrderCreatedBy": "MY020394",
      "lynxOms": "Hybris",
      "orderForSalesAccount": {
        "lynxBusinessStyle": "ROHANA LATIP & WAN ROSLAN",
        "accountId": "8055817",
        "lynxPinLevel": "330",
        "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
        "affiliateCode": "100"
      },
      "lynxPaymentInstalmentType": "PIF",
      "lynxMemberPoints": 0.0,
      "lynxContactPhone": "5494492",
      "totalPVAmount": 95.0,
      "inventoryTransactionRequired": true,
      "lynxIsEventBooking": false,
      "lynxBirCashierId": "MY020394",
      "refunds": [],
      "invoiceWithConsignmentRequired": false,
      "orderPeriod": "202006",
      "orderingSalesAccount": {
        "lynxBusinessStyle": "ROHANA LATIP & WAN ROSLAN",
        "accountId": "8055817",
        "lynxPinLevel": "330",
        "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
        "affiliateCode": "100"
      },
      "lynxContactEmailId": "vhwzezgj@rzrcy.bmh",
      "amwaySalesEntity": "780",
      "paymentStatus": "PAID",
      "storefront": "amwaybrunei",
      "lynxPaymentType": "PIF",
      "salesOrderId": "7100029639",
      "lynxOrderCategory": "selfOrder",
      "payments": [{
        "verificationDate": "2020-06-25T14:05:54.453+08:00",
        "lynxIsConnectedFlow": false,
        "paymentLocation": "T45",
        "lynxPaymentProcessedBy": "8055817",
        "paymentStatus": "ACCEPTED",
        "terminalId": "MY020394",
        "paymentReferenceId": "TXN-1593065154321",
        "payerSalesAccount": {
          "accountId": "8055817",
          "lynxPinLevel": "330",
          "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
          "affiliateCode": "100"
        },
        "paymentDate": "2020-06-25T14:05:54.456+08:00",
        "isoCurrencyCode": "BND",
        "lynxPaymentInformation": "",
        "paymentId": "831122002_4e7c1945-b49d-4c86-a0b8-a05b0cb805fa",
        "paymentValue": 147.5,
        "paymentMethod": "cash",
        "merchantId": "amway"
      }],
      "shipToSalesAccount": {
        "lynxBusinessStyle": "ROHANA LATIP & WAN ROSLAN",
        "accountId": "8055817",
        "lynxPinLevel": "330",
        "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
        "affiliateCode": "100"
      },
      "totalABORetailProfit": 0.0,
      "totalTaxAmount": 0.0,
      "lynxOrderType": "NORMAL_ORDER",
      "lynxComments": []
    }
  },


]



/* Get Result */
function getResult() {
  /* Read value from input fields */
  // var skills = $("#skills").val() || '',
  //   email = $("#email").val() || '',
  order = $("#order").val() || '';
  accountId = $("#accountId").val() || '';


  var result = [],
    i;

  for (i = 0; i < data.length; i++) {
    if ((data[i]["order"]() === order()) || (
        data[i]["accountId"]() === accountId())) {
      result.push(data[i]);
    }
  }

  return result;
};

$('#submit').click(function onClick() {
  var output = getResult();
  var html = '';
  $.each(output, function(key, value) {
    html += '<tr>';
    html += '<td>' + value.order + '</td>';
    html += '<td>' + value.accountId + '</td>';
    html += '<td>' + value.eventType + '</td>';
    html += '<td>' + value.orderDateTime + '</td>';
    html += '<td>' + value.orderStatus + '</td>';

    html += '<td>' + value.totalPVAmount + '</td>';
    html += '<td>' + value.totalBVAmount + '</td>';
    html += '<td>' + value.totalOrderValue + '</td>';
    html += '</tr>';
  });
  $('table tbody').html(html);
});
<title>Order Search</title>
<!-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js">
</script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>

<h1>Order Enquiry</h1>
<div class="container">
  <div class="row">
    <div class="col">
      <p><b>Country</b></P>
      <select class="form-control" name="country" id="country">
        <option class="hidden" selected disabled>Choose</option>
        <option>Malaysia</option>
        <option>Vietnam</option>
        <option>Philippines</option>
      </select>
    </div>
    <div class="col">
      <p><b>Order Type</b></P>
      <select class="form-control" name="name" id="email">
        <option class="hidden" selected disabled>Choose</option>
        <option>Sales order</option>
        <option>Sales Return</option>
      </select>
    </div>
    <div class="col">
      <p><b>Order No.</b></p>
      <input type="number" name="order" id="order" class="form-control">
    </div>
  </div>
  <div class="row">
    <div class="col">
      <p><b>From Date</b></p>
      <input type="datetime-local" name="date" id="date" class="form-control">
    </div>
    <div class="col">
      <p><b>To Date</b></p>
      <input type="datetime-local" name="date" id="date" class="form-control">
    </div>
    <div class="col">
      <p><b>ABO NO</b></p>
      <input type="text" name="accountId" id="accountId" class="form-control">
    </div>
  </div>
  <div class="row">
    <div class="col">
      <p><b>Account Type</b></P>
      <select class="form-control" name="name" id="account">
        <option class="hidden" selected disabled>Choose</option>
        <option>Payment Sales Account</option>
        <option>Volume Sales Account</option>
        <option>Invoice Sales Account</option>
        <option>Ship to Sales Account</option>
        <option>Ordering Sales Account</option>
        <option>Order to Sales Account</option>
      </select>
    </div>
  </div>


  <br>
  <b>
        <br>
    
    
    <input id="submit" type="submit" value="submit">
    <input type="reset" value="Reset">
    </div>
    <br>
    
    
    <!-- <table>
      <thead>
        <tr>
          <th>Order No</th>
          <th>ABO NO</th>
          <th>order Type</th>
           <th>order Date</th>
           <th>order status</th>
                 <th>Total PV</th>
                  <th>Total BV</th>
                   <th>Total Amount</th>
        </tr>
      </thead>
      <tbody>
      </tbody>
    </table> -->
    <div class="container">
        <div class="row col-md-12 col-md-offset-2 custyle">
        <table class="table table-striped custab">
        <thead>
           <tr>
                <th>Order No</th>
          <th>ABO NO</th>
          <th>order Type</th>
           <th>order Date</th>
           <th>order status</th>
            <th>Total PV</th>
            <th>Total BV</th>
            <th>Total Amount</th>
                
            </tr>
        </thead>
            <tbody>
              
            </tbody>    
               
                
        </table>
        </div>
    </div>

【问题讨论】:

  • for (i = 0; i
  • if (data[i]["order"] === order || data[i]["accountId"] === accountId ) {
  • 投票以关闭为 不可重现或由拼写错误引起 虽然类似的问题可能是这里的主题,但这个问题的解决方式不太可能帮助未来的读者。
  • 谢谢。现在我没有收到错误。但也没有得到结果。表格没有显示结果
  • 哦,我的错...由于限制,我没有完全复制有效负载...您的代码运行良好...感谢您为解决此问题提供的帮助和努力

标签: javascript jquery json ajax twitter-bootstrap


【解决方案1】:

在您的 if-statement 中,这两个值 data[i]["order"]data[i]["accountId"] 应该是 data[i].entity.salesOrderIddata[i].eventInfo.accountId。此外,在显示数据时,您使用错误的值从 output 获取数据我已将其更正为好吧。

演示代码

var data = [{
    "eventInfo": {
      "context": {
        "siteTimezone": "Asia/Brunei",
        "entityPk": "8802089762861",
        "entityClass": "de.hybris.platform.core.model.order.OrderModel",
        "com.amway.core.events.model.AmwayEventQueueEntryModel": "8805563195834"
      },
      "isoCountryCode": "BN",
      "eventType": "ORDER_CONFIRMED",
      "entityType": "salesorder",
      "sourceTimestamp": "2020-06-25T14:05:56.683+08:00",
      "sourceApplication": "HYBRIS",
      "affiliateCode": "100",
      "entityId": "7100029639",
      "sourceEventId": "4521231e-c347-459b-8d46-43cd2010c8c1",
      "accountId": "8055817",
      "sourceHost": "ip-10-127-165-135.ap-southeast-1.compute.internal"
    },
    "entity": {
      "lynxIsPCP": false,
      "paymentRequired": true,
      "bonusTransactionRequired": true,
      "addresses": [{
          "telephoneNumber": "03-7946 2800",
          "isoCountryCode": "BN",
          "line3": "Bandar Seri Begawan",
          "cityName": "Brunei",
          "line2": "Kampung Kiulap",
          "line1": "6 & 7, Block A, Kompleks Shakirin",
          "careOfName": "",
          "state": "BR",
          "emailAddress": "vhwzezgj@rzrcy.bmh",
          "postalCode": "BE1518",
          "id": "8804188225559"
        },
        {
          "telephoneNumber": "5494492",
          "isoCountryCode": "BN",
          "line3": "GADONG",
          "line4": "8171571",
          "cityName": "BDR SERI BEGAWAN",
          "line2": "KAMPONG RIMBA",
          "line1": "5 SIMPANG 12-32",
          "careOfName": "",
          "state": "BR",
          "emailAddress": "vhwzezgj@rzrcy.bmh",
          "postalCode": "BE3119",
          "id": "8802223521815"
        },
        {
          "telephoneNumber": "5494492",
          "isoCountryCode": "BN",
          "line3": "GADONG",
          "line4": "8171571",
          "cityName": "BDR SERI BEGAWAN",
          "line2": "KAMPONG RIMBA",
          "line1": "5 SIMPANG 12-32",
          "careOfName": "",
          "state": "BR",
          "emailAddress": "vhwzezgj@rzrcy.bmh",
          "postalCode": "BE3119",
          "id": "8802223521815"
        },
        {
          "telephoneNumber": "03-7946 2800",
          "isoCountryCode": "BN",
          "line3": "Bandar Seri Begawan",
          "cityName": "Brunei",
          "line2": "Kampung Kiulap",
          "line1": "6 & 7, Block A, Kompleks Shakirin",
          "careOfName": "",
          "state": "BR",
          "emailAddress": "myhelpdesk@Amway.com",
          "postalCode": "BE1518",
          "id": "8800157073431"
        }
      ],
      "totalOrderValue": 147.5,
      "lynxPaymentChangePaid": 0.0,
      "lynxIsRepair": false,
      "adjustments": [],
      "requestedDeliveryServiceLevel": "walkin",
      "lynxTenure": 0,
      "saleCountryCode": "BN",
      "orderDateTime": "2020-06-25T14:05:56.328+08:00",
      "invoiceSalesAccount": {
        "lynxBusinessStyle": "ROHANA LATIP & WAN ROSLAN",
        "accountId": "8055817",
        "lynxPinLevel": "330",
        "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
        "affiliateCode": "100"
      },
      "userAgent": "Suresh Mathiarasu",
      "orderStatus": "CONFIRMED",
      "isoCurrencyCode": "BND",
      "fees": [{
        "feeCode": "walkin",
        "feeTaxTotalAmount": 0.0,
        "lynxRefunded": false,
        "feeAmount": 0.0,
        "feeTaxDetails": [{
          "taxAmount": 0.0,
          "taxCode": "BN_NO_SCOPE_VAT_SALES"
        }]
      }],
      "bonusPeriod": "202006",
      "orderingPartyId": "40986385",
      "lynxPayerPartyId": "40986385",
      "salesChannelCode": "Point of Sale",
      "lynxIsEpp": false,
      "lynxPayerPartyName": "ROHANA BINTI HJ LATIP",
      "lynxDemandLocationName": "BN",
      "lynxDeliveryType": "pis",
      "paymentSalesAccount": {
        "lynxBusinessStyle": "ROHANA LATIP & WAN ROSLAN",
        "accountId": "8055817",
        "lynxPinLevel": "330",
        "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
        "affiliateCode": "100"
      },
      "orderPriceList": "AmwayDefaultABOPriceGroup",
      "lynxVolumePartyId": "40986385",
      "lynxHasSopEntries": false,
      "orderLines": [{
        "linePrice": 147.5,
        "itemType": "AmwayVariantProduct",
        "itemBV": 29.5,
        "lynxBirTaxPerUnit": 0.0,
        "lynxInvoiceNumber": "130099000",
        "lynxLineAdjustedPV": 0.0,
        "shippedQuantity": 0,
        "lineStatus": "OPEN",
        "lynxProductSerialNumber": [],
        "lineUnitOfMeasure": "EA",
        "allocatedQuantity": 5,
        "linePVAmount": 95.0,
        "lynxBmCode": [],
        "lastUpdateDate": "2020-06-25T14:05:56.469+08:00",
        "lynxBillingAddressReference": "8802223521815",
        "cancelledQuantity": 0,
        "lynxBaseItemId": "115383D",
        "demandLocation": "T45",
        "backorderedQuantity": 0,
        "taxNotRequired": false,
        "pickupAddressReference": "8804188225559",
        "unallocatedQuantity": 0,
        "pendingQuantity": 5,
        "itemABOPrice": 29.5,
        "lineTaxTotalAmount": 0.0,
        "lynxIsSopLine": false,
        "lynxWasBackorder": false,
        "itemSuggestedRetailPrice": 37.0,
        "lineTotalValue": 147.5,
        "baseItemId": "115383D",
        "lynxMasterCode": [],
        "itemDescription": "ARTISTRY SIGNATURE COLOR Lipstick - Daring Red (06) (3.8g)",
        "lineTaxDetails": [{
          "taxAmount": 0.0,
          "taxCode": "BN_NO_SCOPE_VAT_SALES"
        }],
        "shipAddressReference": "8804188225559",
        "lynxPickupAddressName": "BN",
        "lynxIsSopEntry": false,
        "lynxBirAcknowledgementResetCounter": "1",
        "lynxLineAdjustedBV": 0.0,
        "orderedQuantity": 5,
        "itemListPrice": 29.5,
        "fulfillmentType": "walkin",
        "returnedQuantity": 0,
        "orderLineId": 0,
        "itemPV": 19.0,
        "lineBVAmount": 147.5
      }],
      "lynxFulfillmentAddressReference": "8800157073431",
      "cashierBatchId": "amwaybrunei-AM-BN-BN-T45-MY020394-1593058911313",
      "lynxOrderingPartyName": "ROHANA BINTI HJ LATIP",
      "totalBVAmount": 147.5,
      "lynxVolumeTransactions": [],
      "volumeSalesAccount": {
        "lynxBusinessStyle": "ROHANA LATIP & WAN ROSLAN",
        "accountId": "8055817",
        "lynxPinLevel": "330",
        "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
        "affiliateCode": "100"
      },
      "taxDetails": [{
        "taxAmount": 0.0,
        "taxCode": "BN_NO_SCOPE_VAT_SALES"
      }],
      "lynxUserType": "AmwayBusinessNature_1",
      "lynxPaymentTenderedAmount": 147.5,
      "lynxVolumePartyName": "ROHANA BINTI HJ LATIP",
      "lynxOrderCreatedBy": "MY020394",
      "lynxOms": "Hybris",
      "orderForSalesAccount": {
        "lynxBusinessStyle": "ROHANA LATIP & WAN ROSLAN",
        "accountId": "8055817",
        "lynxPinLevel": "330",
        "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
        "affiliateCode": "100"
      },
      "lynxPaymentInstalmentType": "PIF",
      "lynxMemberPoints": 0.0,
      "lynxContactPhone": "5494492",
      "totalPVAmount": 95.0,
      "inventoryTransactionRequired": true,
      "lynxIsEventBooking": false,
      "lynxBirCashierId": "MY020394",
      "refunds": [],
      "invoiceWithConsignmentRequired": false,
      "orderPeriod": "202006",
      "orderingSalesAccount": {
        "lynxBusinessStyle": "ROHANA LATIP & WAN ROSLAN",
        "accountId": "8055817",
        "lynxPinLevel": "330",
        "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
        "affiliateCode": "100"
      },
      "lynxContactEmailId": "vhwzezgj@rzrcy.bmh",
      "amwaySalesEntity": "780",
      "paymentStatus": "PAID",
      "storefront": "amwaybrunei",
      "lynxPaymentType": "PIF",
      "salesOrderId": "7100029639",
      "lynxOrderCategory": "selfOrder",
      "payments": [{
        "verificationDate": "2020-06-25T14:05:54.453+08:00",
        "lynxIsConnectedFlow": false,
        "paymentLocation": "T45",
        "lynxPaymentProcessedBy": "8055817",
        "paymentStatus": "ACCEPTED",
        "terminalId": "MY020394",
        "paymentReferenceId": "TXN-1593065154321",
        "payerSalesAccount": {
          "accountId": "8055817",
          "lynxPinLevel": "330",
          "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
          "affiliateCode": "100"
        },
        "paymentDate": "2020-06-25T14:05:54.456+08:00",
        "isoCurrencyCode": "BND",
        "lynxPaymentInformation": "",
        "paymentId": "831122002_4e7c1945-b49d-4c86-a0b8-a05b0cb805fa",
        "paymentValue": 147.5,
        "paymentMethod": "cash",
        "merchantId": "amway"
      }],
      "shipToSalesAccount": {
        "lynxBusinessStyle": "ROHANA LATIP & WAN ROSLAN",
        "accountId": "8055817",
        "lynxPinLevel": "330",
        "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
        "affiliateCode": "100"
      },
      "totalABORetailProfit": 0.0,
      "totalTaxAmount": 0.0,
      "lynxOrderType": "NORMAL_ORDER",
      "lynxComments": []
    }
  },
  {
    "eventInfo": {
      "context": {
        "siteTimezone": "Asia/Brunei",
        "entityPk": "8802089762861",
        "entityClass": "de.hybris.platform.core.model.order.OrderModel",
        "com.amway.core.events.model.AmwayEventQueueEntryModel": "8805597503930"
      },
      "isoCountryCode": "BN",
      "eventType": "LYNX_ORDER_UPDATE",
      "entityType": "salesorder",
      "sourceTimestamp": "2020-06-25T14:05:57.250+08:00",
      "sourceApplication": "HYBRIS",
      "affiliateCode": "100",
      "entityId": "7100029639",
      "sourceEventId": "8ab538d6-e525-4c8d-b1cf-411d562715f8",
      "accountId": "8055817",
      "sourceHost": "ip-10-127-165-86.ap-southeast-1.compute.internal"
    },
    "entity": {
      "lynxIsPCP": false,
      "paymentRequired": true,
      "bonusTransactionRequired": true,
      "addresses": [{
          "telephoneNumber": "03-7946 2800",
          "isoCountryCode": "BN",
          "line3": "Bandar Seri Begawan",
          "cityName": "Brunei",
          "line2": "Kampung Kiulap",
          "line1": "6 & 7, Block A, Kompleks Shakirin",
          "careOfName": "",
          "state": "BR",
          "emailAddress": "vhwzezgj@rzrcy.bmh",
          "postalCode": "BE1518",
          "id": "8804188225559"
        },
        {
          "telephoneNumber": "5494492",
          "isoCountryCode": "BN",
          "line3": "GADONG",
          "line4": "8171571",
          "cityName": "BDR SERI BEGAWAN",
          "line2": "KAMPONG RIMBA",
          "line1": "5 SIMPANG 12-32",
          "careOfName": "",
          "state": "BR",
          "emailAddress": "vhwzezgj@rzrcy.bmh",
          "postalCode": "BE3119",
          "id": "8802223521815"
        },
        {
          "telephoneNumber": "5494492",
          "isoCountryCode": "BN",
          "line3": "GADONG",
          "line4": "8171571",
          "cityName": "BDR SERI BEGAWAN",
          "line2": "KAMPONG RIMBA",
          "line1": "5 SIMPANG 12-32",
          "careOfName": "",
          "state": "BR",
          "emailAddress": "vhwzezgj@rzrcy.bmh",
          "postalCode": "BE3119",
          "id": "8802223521815"
        },
        {
          "telephoneNumber": "03-7946 2800",
          "isoCountryCode": "BN",
          "line3": "Bandar Seri Begawan",
          "cityName": "Brunei",
          "line2": "Kampung Kiulap",
          "line1": "6 & 7, Block A, Kompleks Shakirin",
          "careOfName": "",
          "state": "BR",
          "emailAddress": "myhelpdesk@Amway.com",
          "postalCode": "BE1518",
          "id": "8800157073431"
        }
      ],
      "totalOrderValue": 147.5,
      "lynxPaymentChangePaid": 0.0,
      "lynxIsRepair": false,
      "adjustments": [],
      "requestedDeliveryServiceLevel": "walkin",
      "lynxTenure": 0,
      "saleCountryCode": "BN",
      "orderDateTime": "2020-06-25T14:05:56.328+08:00",
      "invoiceSalesAccount": {
        "lynxBusinessStyle": "ROHANA LATIP & WAN ROSLAN",
        "accountId": "8055817",
        "lynxPinLevel": "330",
        "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
        "affiliateCode": "100"
      },
      "userAgent": "Suresh Mathiarasu",
      "orderStatus": "PICKUP_COMPLETE",
      "isoCurrencyCode": "BND",
      "fees": [{
        "feeCode": "walkin",
        "feeTaxTotalAmount": 0.0,
        "lynxRefunded": false,
        "feeAmount": 0.0,
        "feeTaxDetails": [{
          "taxAmount": 0.0,
          "taxCode": "BN_NO_SCOPE_VAT_SALES"
        }]
      }],
      "bonusPeriod": "202006",
      "orderingPartyId": "40986385",
      "lynxPayerPartyId": "40986385",
      "salesChannelCode": "Point of Sale",
      "lynxIsEpp": false,
      "lynxPayerPartyName": "ROHANA BINTI HJ LATIP",
      "lynxDemandLocationName": "BN",
      "lynxDeliveryType": "pis",
      "paymentSalesAccount": {
        "lynxBusinessStyle": "ROHANA LATIP & WAN ROSLAN",
        "accountId": "8055817",
        "lynxPinLevel": "330",
        "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
        "affiliateCode": "100"
      },
      "orderPriceList": "AmwayDefaultABOPriceGroup",
      "lynxVolumePartyId": "40986385",
      "lynxHasSopEntries": false,
      "orderLines": [{
        "linePrice": 147.5,
        "itemType": "AmwayVariantProduct",
        "itemBV": 29.5,
        "lynxBmCode": [],
        "lynxInvoiceNumber": "130099000",
        "lynxLineAdjustedPV": 0.0,
        "shippedQuantity": 5,
        "lineStatus": "OPEN",
        "lynxProductSerialNumber": [],
        "lineUnitOfMeasure": "EA",
        "allocatedQuantity": 5,
        "linePVAmount": 95.0,
        "fulfillments": [{
          "fulfillmentLocation": "T45",
          "fulfilledItemRevision": "",
          "fulfilledSKU": "115383D",
          "uniqueFulfillmentID": "100000002118",
          "fulfilledBaseItemId": "115383D",
          "fulfilledDate": "2020-06-25T14:05:57.167+08:00",
          "fulfilledItemLot": "",
          "fulfilledQuantity": 5
        }],
        "actualShipDate": "2020-06-25T14:05:57.167+08:00",
        "lastUpdateDate": "2020-06-25T14:05:56.985+08:00",
        "lynxBillingAddressReference": "8802223521815",
        "cancelledQuantity": 0,
        "lynxBaseItemId": "115383D",
        "demandLocation": "T45",
        "backorderedQuantity": 0,
        "taxNotRequired": false,
        "lynxLineFulfillmentStatus": "SHIPPED",
        "lynxBirTaxPerUnit": 0.0,
        "pickupAddressReference": "8804188225559",
        "unallocatedQuantity": 0,
        "pendingQuantity": 0,
        "itemABOPrice": 29.5,
        "lineTaxTotalAmount": 0.0,
        "lynxIsSopLine": false,
        "lynxWasBackorder": false,
        "itemSuggestedRetailPrice": 37.0,
        "lineTotalValue": 147.5,
        "baseItemId": "115383D",
        "lynxMasterCode": [],
        "itemDescription": "ARTISTRY SIGNATURE COLOR Lipstick - Daring Red (06) (3.8g)",
        "lineTaxDetails": [{
          "taxAmount": 0.0,
          "taxCode": "BN_NO_SCOPE_VAT_SALES"
        }],
        "shipAddressReference": "8804188225559",
        "lynxPickupAddressName": "BN",
        "lynxIsSopEntry": false,
        "lynxBirAcknowledgementResetCounter": "1",
        "lynxLineAdjustedBV": 0.0,
        "orderedQuantity": 5,
        "itemListPrice": 29.5,
        "fulfillmentType": "walkin",
        "returnedQuantity": 0,
        "actualDeliveryDate": "2020-06-25T14:05:57.167+08:00",
        "orderLineId": 0,
        "itemPV": 19.0,
        "lineBVAmount": 147.5
      }],
      "lynxFulfillmentAddressReference": "8800157073431",
      "cashierBatchId": "amwaybrunei-AM-BN-BN-T45-MY020394-1593058911313",
      "lynxOrderingPartyName": "ROHANA BINTI HJ LATIP",
      "totalBVAmount": 147.5,
      "lynxVolumeTransactions": [{
        "lynxInterfaceType": "ORDERS",
        "lynxInterfaceAttribute": "positive",
        "lynxPointValue": 95.0,
        "lynxTransactionTime": "2020-06-25T14:05:56.981+08:00",
        "lynxStatus": "CREATED",
        "lynxTransactionType": "ORDER",
        "lynxBonusPeriod": "202006",
        "lynxBusinessValue": 147.5
      }],
      "volumeSalesAccount": {
        "lynxBusinessStyle": "ROHANA LATIP & WAN ROSLAN",
        "accountId": "8055817",
        "lynxPinLevel": "330",
        "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
        "affiliateCode": "100"
      },
      "taxDetails": [{
        "taxAmount": 0.0,
        "taxCode": "BN_NO_SCOPE_VAT_SALES"
      }],
      "lynxUserType": "AmwayBusinessNature_1",
      "lynxPaymentTenderedAmount": 147.5,
      "lynxVolumePartyName": "ROHANA BINTI HJ LATIP",
      "lynxOrderCreatedBy": "MY020394",
      "lynxOms": "Hybris",
      "orderForSalesAccount": {
        "lynxBusinessStyle": "ROHANA LATIP & WAN ROSLAN",
        "accountId": "8055817",
        "lynxPinLevel": "330",
        "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
        "affiliateCode": "100"
      },
      "lynxPaymentInstalmentType": "PIF",
      "lynxMemberPoints": 0.0,
      "lynxContactPhone": "5494492",
      "totalPVAmount": 95.0,
      "inventoryTransactionRequired": true,
      "lynxIsEventBooking": false,
      "lynxBirCashierId": "MY020394",
      "refunds": [],
      "invoiceWithConsignmentRequired": false,
      "orderPeriod": "202006",
      "orderingSalesAccount": {
        "lynxBusinessStyle": "ROHANA LATIP & WAN ROSLAN",
        "accountId": "8055817",
        "lynxPinLevel": "330",
        "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
        "affiliateCode": "100"
      },
      "lynxContactEmailId": "vhwzezgj@rzrcy.bmh",
      "amwaySalesEntity": "780",
      "paymentStatus": "PAID",
      "storefront": "amwaybrunei",
      "lynxPaymentType": "PIF",
      "salesOrderId": "7100029639",
      "lynxOrderCategory": "selfOrder",
      "payments": [{
        "verificationDate": "2020-06-25T14:05:54.453+08:00",
        "lynxIsConnectedFlow": false,
        "paymentLocation": "T45",
        "lynxPaymentProcessedBy": "8055817",
        "paymentStatus": "ACCEPTED",
        "terminalId": "MY020394",
        "paymentReferenceId": "TXN-1593065154321",
        "payerSalesAccount": {
          "accountId": "8055817",
          "lynxPinLevel": "330",
          "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
          "affiliateCode": "100"
        },
        "paymentDate": "2020-06-25T14:05:54.456+08:00",
        "isoCurrencyCode": "BND",
        "lynxPaymentInformation": "",
        "paymentId": "831122002_4e7c1945-b49d-4c86-a0b8-a05b0cb805fa",
        "paymentValue": 147.5,
        "paymentMethod": "cash",
        "merchantId": "amway"
      }],
      "shipToSalesAccount": {
        "lynxBusinessStyle": "ROHANA LATIP & WAN ROSLAN",
        "accountId": "8055817",
        "lynxPinLevel": "330",
        "lynxName": "ROHANA BINTI HJ LATIP & WAN ROSLAN B WAN SU",
        "affiliateCode": "100"
      },
      "totalABORetailProfit": 0.0,
      "totalTaxAmount": 0.0,
      "lynxOrderType": "NORMAL_ORDER",
      "lynxComments": []
    }
  }
]



/* Get Result */
function getResult() {
  order = $("#order").val() || '';
  accountId = $("#accountId").val() || '';

  var result = [],
    i;

  for (i = 0; i < data.length; i++) {
  //here you need to get data->entity->salesOrderId ,Also for accountId it is under eventInfo
   if (data[i].entity.salesOrderId  === order ||data[i].eventInfo.accountId === accountId )  {
   
      result.push(data[i]);
    }
  }

  return result;
};

$('#submit').click(function() {
//console.log("in")
  var output = getResult();
  var html = '';
  $.each(output, function(key, value) {
  //changes made accordingly
    html += '<tr>';
    html += '<td>' + value.entity.salesOrderId + '</td>';
    html += '<td>' + value.eventInfo.accountId + '</td>';
    html += '<td>' + value.eventInfo.eventType + '</td>';
    html += '<td>' + value.entity.orderDateTime + '</td>';
    html += '<td>' +  value.entity.orderStatus + '</td>';
    html += '<td>' +  value.entity.totalPVAmount + '</td>';
    html += '<td>' +  value.entity.totalBVAmount + '</td>';
    html += '<td>' +  value.entity.totalOrderValue + '</td>';
    html += '</tr>';
  });
 
  $('table tbody').html(html);
});
<title>Order Search</title>
<!-- <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js">
</script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>

<h1>Order Enquiry</h1>
<div class="container">
  <div class="row">
    <div class="col">
      <p><b>Country</b></P>
      <select class="form-control" name="country" id="country">
        <option class="hidden" selected disabled>Choose</option>
        <option>Malaysia</option>
        <option>Vietnam</option>
        <option>Philippines</option>
      </select>
    </div>
    <div class="col">
      <p><b>Order Type</b></P>
      <select class="form-control" name="name" id="email">
        <option class="hidden" selected disabled>Choose</option>
        <option>Sales order</option>
        <option>Sales Return</option>
      </select>
    </div>
    <div class="col">
      <p><b>Order No.</b></p>
      <input type="number" name="order" id="order" class="form-control">
    </div>
  </div>
  <div class="row">
    <div class="col">
      <p><b>From Date</b></p>
      <input type="datetime-local" name="date" id="date" class="form-control">
    </div>
    <div class="col">
      <p><b>To Date</b></p>
      <input type="datetime-local" name="date" id="date" class="form-control">
    </div>
    <div class="col">
      <p><b>ABO NO</b></p>
      <input type="text" name="accountId" id="accountId" class="form-control">
    </div>
  </div>
  <div class="row">
    <div class="col">
      <p><b>Account Type</b></P>
      <select class="form-control" name="name" id="account">
        <option class="hidden" selected disabled>Choose</option>
        <option>Payment Sales Account</option>
        <option>Volume Sales Account</option>
        <option>Invoice Sales Account</option>
        <option>Ship to Sales Account</option>
        <option>Ordering Sales Account</option>
        <option>Order to Sales Account</option>
      </select>
    </div>
  </div>


  <br>
  <b>
        <br>
    
    
    <input id="submit" type="submit" value="submit">
    <input type="reset" value="Reset">
    </div>
    <br>
    
    
    <!-- <table>
      <thead>
        <tr>
          <th>Order No</th>
          <th>ABO NO</th>
          <th>order Type</th>
           <th>order Date</th>
           <th>order status</th>
                 <th>Total PV</th>
                  <th>Total BV</th>
                   <th>Total Amount</th>
        </tr>
      </thead>
      <tbody>
      </tbody>
    </table> -->
    <div class="container">
        <div class="row col-md-12 col-md-offset-2 custyle">
        <table class="table table-striped custab">
        <thead>
           <tr>
                <th>Order No</th>
          <th>ABO NO</th>
          <th>order Type</th>
           <th>order Date</th>
           <th>order status</th>
            <th>Total PV</th>
            <th>Total BV</th>
            <th>Total Amount</th>
                
            </tr>
        </thead>
            <tbody>
              
            </tbody>    
               
                
        </table>
        </div>
    </div>

【讨论】:

  • 哇。非常感谢斯瓦蒂。你真棒 !欣赏你的编码技巧
  • 我想得到 5 行作为输出,因为有 5 个有效载荷,但我只得到 2 行 OP。不知道为什么
  • 哪个5 payloads ?他们在哪 ?你能指出来吗?
  • 完成...我有疑问...如果我有一个 JSON 文件保存在云或任何其他地方,代码是如何工作的?因为这里我们已经把JS里的代码写对了..
  • “RESET”按钮不起作用的原因是什么?
猜你喜欢
  • 2020-10-18
  • 2020-10-25
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-12-06
  • 2023-01-24
相关资源
最近更新 更多