我正在遍历我的 JSON 响应。我有以 id 作为参数名称的 HTML 元素。
例如,我的 JSON 响应包含一个"costcenter":"1234",并且有一个<span>带有 id 的元素costcenter。
现在,我认为我可以遍历 JSON 数组并自动读取其名称,而不是为每个 id 编写语句。
这就是我得到的
$(".dataset").click(function() {
    changeid = this.id;
    $.ajax({
        url: "source",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        data: {
            id: changeid
        },
        success: function(data) {
            // How to get the name of the parameter, and then read it's value?
        }
    })
})
JSON 看起来像这样,它只是一维和 1 个结果集:
{"changeid":"1","costcenter":"478","manager":"John Smith"}