gpt4 book ai didi

javascript - 从jsp页面获取ajax请求数据

转载 作者:太空宇宙 更新时间:2023-11-04 12:22:53 26 4
gpt4 key购买 nike

我在 JSP 中有这段代码

        Map<String, Long> map = new HashMap<String, Long>();
map.put("A", 10L);
map.put("B", 20L);
map.put("C", 30L);

JSONObject json = new JSONObject();
json.accumulateAll(map);

System.out.println(json.toString());


List<String> list = new ArrayList<String>();
list.add("Sunday");
list.add("Monday");
list.add("Tuesday");

json.accumulate("weekdays", list);
System.out.println(json.toString());

打印

Info:   2
Info: {"A":10,"B":20,"C":30}
Info: {"A":10,"B":20,"C":30,"weekdays":["Sunday","Monday","Tuesday"]}

在 netbeans 的输出中

我的ajax是

var id = $(this).attr('data-id');

$.ajax({
type: 'POST',
url: '../include/residents.jsp',
dataType: "json",
data: {
id: id,
},
success: function(data) {},
error: function(data) {}
}).done(function() {
});

如何在ajax success或done函数中显示这些输出数据?

最佳答案

尝试输出 json 一次

System.out.print(json);
System.out.flush();

在ajax中使用appendeach的组合来循环工作日

关于javascript - 从jsp页面获取ajax请求数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38650498/

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