尝试显示json内容

时间:2016-08-08 02:39:44

标签: javascript jquery json

以下是我所指的JSON内容:

{
  "webservice_status": {
    "status": "SUCCESS",
    "message": ""
  },
  "dailyroster": [
    {
      "webservice_status": null,
      "recordNumber": "3014973",
      "first_date": "2016-04-27",
      "first_recordType": "BM Specimen",
      "record_id": 0

    },
    {
      "webservice_status": null,
      "recordNumber": "3014973",
      "first_date": "2016-04-27",
      "first_recordType": "BM Specimen",
      "record_id": 0

    },
    {
      "webservice_status": null,
      "recordNumber": "3014973",
      "first_date": "2016-04-27",
      "first_recordType": "BM Specimen",
       "record_id": 0

    }

  ]
}

我正在尝试使用下面定义的fetchInfo函数中的jQuery AJAX调用来检索信息:

this.fetchInfo = function (recordNumber_,recordType_,recordDate_) {

        // some code here


        var ajaxRequest = jQuery.ajax({

            data: {
                record_id: rg.record.id,
                recordNumber: recordNumber_,
                first_recordType: recordType_,
                first_date: recordDate_

            },
            dataType: "json",
            method: "GET",
            url: url
        })
        .done(function (data_, textStatus_, jqXHR_) {

            // some code

           var json_contents = data_.dailyroster;

           console.log("Attempt to display Doc Contents: "+json_contents[1]);

           // some code below

        }

    } 

以下是我继续获取的控制台日志中的消息:

Attempt to display Doc Contents: [object Object]

我做错了吗?

1 个答案:

答案 0 :(得分:1)

我认为你做得对。 json_contents是JsonArray.so的一个实例,json_contents [1]是控制台中JsonObject.you消息的一个实例。 如果你想详细说明你,你应该这样发送: 的 json_content [1] .webservice_status