weixin_33671935 2017-11-30 06:33 采纳率: 0%
浏览 118

JSON AJAX返回“未定义”

Im trying to get a simple json on my ajax to asign the values to some inputs on my page, but i always get a undefined on my ajax alert

This is my JSON:

{"data":[{"Line_Number":10,"PO_Number":"P072592-1","Date":"9-07-17","Item_Number":"12789 - ","Size":"S","Description":"HDW- HINGE- PIANO- BLACK STAINLESS- .125 DIA.- HD SERIES","Delivery":"12-18-17","Quantity":800.0000,"Unit":"PCS","Unit_Price":0.8600,"Amount":"688"}]}

And this is my Ajax Call:

$.ajax({
    type: "GET",
    dataType: "json",
    url: '@Url.Action("GetOrder","Orders")/' + val,
    //data: { po_number: 'value' },
    success: function (data) {
        alert(data[0].Date)
    },
    error: function () {
         alert('Some error occurred!');
    }
});

However i always get a Undefined on my alert and what i need is my "Date" Value What am i doing wrong?

  • 写回答

3条回答 默认 最新

  • weixin_33736649 2017-11-30 06:37
    关注

    As I see your data is

    {"data":[{"Line_Number":10,"PO_Number":"P072592-1","Date":"9-07-17","Item_Number":"12789 - ","Size":"S","Description":"HDW- HINGE- PIANO- BLACK STAINLESS- .125 DIA.- HD SERIES","Delivery":"12-18-17","Quantity":800.0000,"Unit":"PCS","Unit_Price":0.8600,"Amount":"688"}]}
    

    so you should try this once

    data.data[0].Date
    
    评论

报告相同问题?

悬赏问题

  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥15 stable diffusion
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘