我有一个 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.html
和jsp
没有关系。你不应该把它放在 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/