【发布时间】:2021-01-13 22:01:33
【问题描述】:
我是使用 AJAX 编程的新手。目前,我收到一个 404 错误代码,但我不太确定出了什么问题,如果有人能提供帮助,我将不胜感激。我正在尝试使用用户输入来访问数据库。我正在使用 AJAX 向控制器发送数据,但控制器没有接收到 AJAX 请求。如果有人可以提供帮助,我将不胜感激。
错误代码是:
jquery.min.js:6 GET http://localhost:8080/GCSE/student_report/7days_report/?username=v 404
这是我的 ajax 代码
$(document).ready(function(){
$("#username").keyup(function(){
console.log($("#username").val());
$.ajax({
type: "GET",
url:
"/GCSE/student_report/7days_report/?username="+$("#username").val(),
success: function(result){
$("#name").html(result);
}
});
});
});
这是控制器代码
@RequestMapping(value = "/GCSE/student_report/7days_report/{username}")
public ModelAndView getGCSEReportBy_JSON() {
Report GCSE = ps.getReportsWithUsernamePrefix(username);
return new ModelAndView("index", "data", GCSE);
}
PS 服务代码
@Autowired
private ReportRepository rrRepo;
public Iterable<Report> getAllReports(){
return rrRepo.findAll();
}
杰夫干杯
【问题讨论】:
标签: ajax spring controller