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 虚拟机打包apk出现错误
  • ¥30 最小化遗憾贪心算法上界
  • ¥15 用visual studi code完成html页面
  • ¥15 聚类分析或者python进行数据分析
  • ¥15 逻辑谓词和消解原理的运用
  • ¥15 三菱伺服电机按启动按钮有使能但不动作
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝