包含数组对象的JSON-Ajax调用结果为空

时间:2019-01-08 23:44:54

标签: javascript json ajax

我有以下JSON来源 enter image description here

我的两个名称/值对kpiRecordedMissesNoPlannerMatchgoodShipmentPlannerSaidMissed包含对象数组。

当我进行ajax调用时,数组将变为空。 enter image description here

这是我用来进行ajax调用的代码。

var urlString = '../api/APILPlus/APILPlusMissingComments/PS/DMPSPM/2018-11-01/2018-11-30';

$.ajax({
    type: 'GET',
    dataType: 'json',
    contentType: "application/json",
    url: urlString,
    success: function (json) {

        console.log('json'); console.log(json);

    }
});

当我对来自浏览器的相同JSON输出进行硬编码时,数组将按预期填充。

var manualJson = [{ "dels": 116, "kpiRecordedMissesNoPlannerMatch": [{ "delivery": "1188724924", "material": "0281006949562", "materialDesc": "Particulate matter p", "sum": 0.00, "cause": "No Planner answer." }, { "delivery": "1188771856", "material": "0281006949562", "materialDesc": "Particulate matter p", "sum": 0.00, "cause": "No Planner answer." }, { "delivery": "1188644995", "material": "0281006950562", "materialDesc": "Particulate matter p", "sum": 0.00, "cause": "No Planner answer." }, { "delivery": "1188740584", "material": "02810075106RY", "materialDesc": "Particulate matter p", "sum": 0.00, "cause": "No Planner answer." }, { "delivery": "1188740588", "material": "02810075106RY", "materialDesc": "Particulate matter p", "sum": 0.00, "cause": "No Planner answer." }, { "delivery": "1188711251", "material": "02810079346RY", "materialDesc": "Particulate matter p", "sum": 0.00, "cause": "No Planner answer." }, { "delivery": "1188772925", "material": "02810079346RY", "materialDesc": "Particulate matter p", "sum": 0.00, "cause": "No Planner answer." }, { "delivery": "1188644995", "material": "0281006954562", "materialDesc": "Particulate matter p", "sum": 0.00, "cause": "No Planner answer." }, { "delivery": "1188786351", "material": "02810072632G9", "materialDesc": "Particulate matter p", "sum": 50.00, "cause": "No Planner answer." }, { "delivery": "1188740585", "material": "02810069446RY", "materialDesc": "Particulate matter p", "sum": 0.00, "cause": "No Planner answer." }, { "delivery": "1188740582", "material": "02810075146RY", "materialDesc": "Particulate matter p", "sum": 0.00, "cause": "No Planner answer." }, { "delivery": "1188770521", "material": "02810078782G9", "materialDesc": "Particulate matter p", "sum": 0.00, "cause": "No Planner answer." }, { "delivery": "1188805487", "material": "02810065116RY", "materialDesc": "Particulate matter p", "sum": 50.00, "cause": "No Planner answer." }, { "delivery": "1188740583", "material": "02810075126RY", "materialDesc": "Particulate matter p", "sum": 0.00, "cause": "No Planner answer." }, { "delivery": "1188711238", "material": "02810079366RY", "materialDesc": "Particulate matter p", "sum": 0.00, "cause": "No Planner answer." }, { "delivery": "1188772925", "material": "02810079366RY", "materialDesc": "Particulate matter p", "sum": 0.00, "cause": "No Planner answer." }], "goodShipmentPlannerSaidMissed": [{ "delivery": "1188691604", "material": "02810072632G9", "materialDesc": "Particulate matter p", "sum": 100.00, "cause": "Supplier Backlog/ Late", "m11": 100.00 }, { "delivery": "1188659715", "material": "02810074965UR", "materialDesc": "Particulate matter p", "sum": 100.00, "cause": "Supplier Backlog/ Late", "m11": 100.00 }] }];
console.log('manualJson'); console.log(manualJson);

enter image description here

我不明白我在想什么。帮助一如既往!

更新: 附加信息。浏览器中的网络控制台。 enter image description here

1 个答案:

答案 0 :(得分:0)

我找到了!我的JavaScript中的网址日期范围不完全正确。我已将计算更正为包括整个月日期范围(肯定有数据)。

这是网络控制台。 enter image description here

和预期的最终JSON。 enter image description here

感谢今天晚上与我一起工作的所有人。非常感谢您的评论!