gpt4 book ai didi

jquery - Ajax 查询不成功

转载 作者:行者123 更新时间:2023-11-28 02:58:41 25 4
gpt4 key购买 nike

我有一个 html 页面的 Ajax 查询,但它总是失败。 html页面是这样的只有一个 <h1>带有一些文本的标签。

谁能告诉我为什么会这样

$.ajax({
url: "http://localhost:8080/FindMySize/src/main/webapp/WEB-INF/jsp/result.html",
success: function(data) {
$('#stage').html(data);
},
error: function(data) {
$('#stage').html("AS");
}

});

最佳答案

您的 javascript 没问题。

问题是你的Java结构,这里的文件result.htmljsp没有关系。你不应该把它放在 WEB-INF 里面。参见 this所以回答以获得更清楚的理解。

The WEB-INF node is not part of the public document tree of the application. No file contained in the WEB-INF directory may be served directly to a client by the container

解决方案:将您的 html 移动到 public 文件夹(您存储 javascript、css、img 等的地方)

关于jquery - Ajax 查询不成功,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35643812/

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