代码之家  ›  专栏  ›  技术社区  ›  cmill

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

  •  -2
  • cmill  · 技术社区  · 6 年前

    我有以下JSON源代码 enter image description here

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

    当我进行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 回复  |  直到 6 年前
        1
  •  0
  •   cmill    6 年前

    我找到了!我的javascript中的URL日期范围不完全正确。我已经修正了计算,包括完整的月份日期范围(其中肯定有数据)。

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

    以及预期的最终JSON。 enter image description here

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