gpt4 book ai didi

javascript - 在 HTML 表中显示 JSON 字符串数据

转载 作者:行者123 更新时间:2023-12-03 06:44:01 24 4
gpt4 key购买 nike

我从服务器获取以下 JSON 字符串作为响应 enter image description here这是我的 Jquery 代码

function loadCategories() {
$.ajax({
type: "POST",
url: "/Services/ControllerService.asmx/Get",
data: {},
cache: false,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result) {
var jsonArray = JSON.parse(result.d);

alert(jsonArray);




}, error: function (msg) {
alert('Error : while executing the outlets : ' + msg.responseText);
}
});
}

警报正确显示 JSON 字符串。现在我想将此响应映射到显示“a”和“b”列的 html 表格

  a        -             b

hasOtherInfo Undergratuate_in_Computing_Faculty

我怎样才能做到这一点?

最佳答案

  1. 循环遍历 JSON 数据。
  2. 获取 a 和 b 值
  3. 编写一个函数,负责根据/和 # 拆分 results.a.bindings.value 和 results.b.bindings.value 中存在的值

  4. 在 html 表格中显示相同内容5(可选)。使用 jquery 表插件来显示结果,以获得良好的外观

关于javascript - 在 HTML 表中显示 JSON 字符串数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37828652/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com