[英]Uncaught TypeError: Cannot read property 'toUpperCase' of undefined
[英]why do i see this error :Cannot read property 'toUpperCase' of undefined while running my page?
我寫了一個代碼來將 JSON Object 讀入 Bootstrap 表。 最初代碼是有效的。 后來我將整個文件夾移動到桌面。 當我再次嘗試時,我開始收到錯誤。 我不確定出了什么問題。
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"].toUpperCase() === order.toUpperCase()) || (
data[i]["accountId"].toUpperCase() === accountId.toUpperCase()) ) {
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);
});
但是當運行代碼時,我收到如下錯誤消息:
Uncaught TypeError: Cannot read property 'toUpperCase' of undefined
at getResult (script.js:1470)
at HTMLInputElement.onClick (script.js:1479)
at HTMLInputElement.dispatch (jquery.min.js:2)
at HTMLInputElement.v.handle (jquery.min.js:2)
有人可以幫我解決這個問題嗎? 當我讓我的朋友嘗試時,它在她的系統中工作。 我不確定出了什么問題。
也許數據中有一些未定義的帳戶或訂單值。
var b;
b.toUpperCase()
你會看到和你一樣的錯誤。
const selectedOrder = order && order.toUpperCase();
const currentOrder = data[i]["order"] && data[i]["order"].toUpperCase();
const selectedAccoundId = accoundId && accoundId.toUpperCase();
const currentAccoundId = data[i]["accountId"].toUpperCase()
if (selectedOrder === currentOrder || selectedOrder === currentAccoundId) {
result.push(data[i]);
}
您可以在 for 循環中添加它。 這將解決您的問題...
從理論上講,訂單和帳戶 ID 應該始終存在。 因此,我想請您檢查數據中是否也缺少某些內容。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.