我已經閱讀了多篇關于此的文章和問題,但似乎沒有一個建議對我有用。我有一個 ajax 調用返回的 json 結果,我想將結果的每個值放入輸入字段中。我已經很接近了,“JSON.stringify(data)”正在我的輸入字段中返回我的完整結果。但是我如何從中獲取“恢復”值呢?完整數據結果如下所示:{"data":{"id":12,"name":"hello","addDt":"2020-11-06T00:00:00","recovery":"hello","latestRecovery":"hello","latestSituation":"hello","nextSteps":"hello","requestId":null}}這是我當前的 ajax 調用: function LoadUpdate(id) { $.ajax({ url: "?handler=updateValuesJson&id=" + id, type: "GET", dataType: "json", async: false, success: function (data) { document.getElementById("recovery").innerHTML = JSON.stringify(data); // I need "recovery" element from this string result $("#updatemodal").modal(); } }); }我嘗試過的:JSON.stringify(data) 是完整的字符串結果(但我需要“recovery”的值)JSON.stringify(data.recovery) 是“未定義”JSON.stringify(data[3]) 是“未定義”數據是“[對象對象]”data.recovery 是“未定義”數據[“恢復”]是“未定義”JSON.parse(data)[i]['recovery'] 不成功我是 ajax/json 的新手 - 我在這里不明白什么?
如何從ajax調用的json結果中的數據中獲取指定元素?
侃侃爾雅
2023-07-20 16:18:07