Javascript 为什么会出现此错误:无法读取属性';toUpperCase';运行我的页面时未定义的错误?
我编写了一段代码,将JSON对象读入引导表。最初代码是有效的。后来我把整个文件夹移到了桌面上。当我再次尝试时,我开始出错。我不确定出了什么问题Javascript 为什么会出现此错误:无法读取属性';toUpperCase';运行我的页面时未定义的错误?,javascript,html,jquery,ajax,twitter-bootstrap,Javascript,Html,Jquery,Ajax,Twitter Bootstrap,我编写了一段代码,将JSON对象读入引导表。最初代码是有效的。后来我把整个文件夹移到了桌面上。当我再次尝试时,我开始出错。我不确定出了什么问题 var data = [{ "eventInfo": { "context": { "siteTimezone": "Asia/Brunei", "entityPk": "
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);
});
有人能帮我解决这个问题吗?当我请我的朋友尝试时,它在她的系统中工作。我不确定出了什么问题。数据中可能有一些帐户或订单的未定义值
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应该始终存在。因此,我想请您检查数据中是否也缺少某些内容。向我们展示一个导致错误的
数据样本,请您现在检查一下好吗?您有数据[I][“订单”]
在您的if语句中,但是您的数据没有任何名为order的对象属性
在运行for循环之前,您应该使用console.log()检查这些值。如果值未定义,它可能会揭示一些问题。另外,我刚刚注意到,您没有声明order,只说order=。。。您应该使用let order=。。。accountId也是如此,我为(i=0;iconst 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]);
}