In a web page, I want to provide some buttons to do some actions, for example, delete user. I don't want to create one form for each button, so I thought an ajax post request would be the best way to accomplish this. For some reason the URL is not intercepted by the controller, only if I add the project's name then it would work (e.g. url : "projectname/users/remove"). I obviously don't want to hard code the project name on every ajax request nor have a project name variable. What would be the right way to make such a request by only specifying "/users/remove" for the url/action?
function removeUser(userid){
var r = confirm("Are you sure you want to delete user '" + userid + "''?");
if (r == true) {
$.ajax({
type : "POST",
url : "/users/remove",
data : {
userid: userid
},
success : function(response) {
alert("Suceeded!");
},
error : function(e) {
alert('Failed!: ' + e);
}
});
}
}
Thanks in advance Diego