【发布时间】:2015-07-31 05:21:18
【问题描述】:
$(document).ready(function () {
$(".linkDelete").click(function () {
var userid = $(this).attr("id");
console.debug("saurabh userid", userid);
var url = "/delete?id=" + userid;
var s = "SpringHibernateAnnotations";
console.debug("saurabh url", url);
$.ajax({
url: s + "/delete?id=" + userid,
success: function (data) {
$('#result').html(data);
}
});
});
});
我有这个 jquery ajax 函数,它正在生成这个 url 获取http://localhost:8080/SpringHibernateAnnotations/SpringHibernateAnnotations/delete?id=253 404(未找到) 相反,它应该生成 http://localhost:8080/SpringHibernateAnnotations/delete?id=253 404 如果我删除 var s= "SpringHibernateAnnotations";并将我的 url 在 ajax 方法中保留为 url :“/delete?id="+userid, 它生成 http://localhost:8080/delete?id=253 因为我无法进入应用程序。那么我怎样才能生成这个正确的 url http://localhost:8080/SpringHibernateAnnotations/delete?id=253
【问题讨论】: