0
我想使用ajax
和spring mvc
刪除多個行,但它總是刪除一行。如何使用ajax和spring刪除多行數據庫mvc
//code controller
@RequestMapping(value = "/rmvclientserviceajax", method = RequestMethod.POST)
@ResponseBody
public void rmvclintServiceajax (HttpServletRequest request, Model model)
{
for(String serviceID: request.getParameterValues("idService"))
{ Long clientID = (long) Integer.parseInt(request.getParameter("idClient"));
metiersr.deleteClientToService(clientID,(long) Integer.parseInt(serviceID));}
}
//code js
function AjaxPostdelete() {
if ($('#idService').prop('checked')) {
var idService = $('#idService').val();
var idClient = $('#idClient').val();
$.ajax({
type : "POST",
url : "/cp/client/rmvclientserviceajax",
data : "idClient=" + idClient + "&idService=" + idService,
success : function(response) {
{
{
}
}
// code html
<form>
<ul class="liste_servch">
<input type="hidden" id="idClient" value="${client.idPersonne}" />
<c:forEach items="${listservclt}" var="servclt">
<li>
<input id="idService" type="checkbox" value="${servclt.idService}" />
<c:out value="${servclt.nomService}" />
</li>
</c:forEach>
</ul>
<input type="button" value="supp" onclick="AjaxPostdelete() ">
</form>
你想發佈您的js代碼嗎? – Mippy
你可以用serviceID中的值來打你的控制器方法嗎? 更好地發佈你的JS代碼和錯誤日誌。 –
@Mippy我加了我的代碼js, – Raki