我没有得到json数据它的投掷错误......任何人都可以建议

时间:2016-03-08 05:45:37

标签: jquery json ajax

$.ajax({
    type: "GET",
    dataType: "json",
    url:https://www.formstack.com/api/v2/form/2288422/notification.json?oauth_token=88d99cf491d4a77576c2d151ab26a293",
    error: function (XMLHttpRequest, textStatus, errorThrown) {
        alert("Request: " + XMLHttpRequest.toString() + "\n\nStatus: " + textStatus + "\n\nError: " + errorThrown);
    },
    success: function (result) {
        location.reload(true);
    }
});

1 个答案:

答案 0 :(得分:1)

$.ajax({
    type: "GET",
    dataType: "json",
    url:"https://www.formstack.com/api/v2/form/2288422/notification.json?oauth_token=88d99cf491d4a77576c2d151ab26a293",
    error: function (XMLHttpRequest, textStatus, errorThrown) {
        console.log(XMLHttpRequest, textStatus, errorThrown)
    },
    success: function (result) {
        console.log(result)
    }
});

返回的JSON数据是:

{ 
  notifications: [{
    _retries: 0,
    attach_limit: "0",
    editor: "wysiwyg",
    form: "2288422",
    format: "html",
    hide_empty: "0",
    id: "4125434",
    name: "Notification Email",
    recipients: "xxxxxxxx@gmail.com",
    show_section: "0",
    subject: "",
    table: "notificationEmail",
    type: "data"
  }]
}

加入" id"例如,使用result.notifications[0].id