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
    
    评论

报告相同问题?

悬赏问题

  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况
  • ¥15 画两个图 python或R