<div>
<c:forEach var="i" items="${requestScope.out}">
<div productform="${i.id}">
<div name="iduser" value="${i.idUser}">
<p><c:out value="${i.typeProduct}"></c:out></p>
<p name="model" value="${i.model}"><c:out value="${i.model}"></c:out></p>
<p name="smodel" value="${i.smodel}"><c:out value="${i.smodel}"></c:out></p>
<p id="cost_item"><c:out value="${i.cost}"></c:out></p>
<p>-----------------------------------------</p>
</div>
<button product="${i.id}" type="button" class="btn_delete">Удалить из корзины</button>
</div>
</c:forEach>
</div>
(function($) {
$(document).ready(function() {
$('.btn_delete').click(function() {
var basketID = $(this).attr('product');
var from = $('div[productform="' + basketID + '"]');
var cost = parseInt($('#cost_item'));
console.log(cost);
var data = {};
var child = $(from.children()[0]);
data[child.attr("name")] = child.attr("value");
$(child.find('p[name]')).each(function (index, el) {
data[$(el).attr('name')] = $(el).attr("value");
});
$.ajax({
type: 'POST',
data: data,
url: 'basket',
success: function(result) {
var el = $('#cost');
console.log( "el " + el.html());
var v = parseInt(el.html());
console.log("v " + v);
el.html(v - cost);
console.log( "el " + el.html());
// $('#cost') = el;
from.remove();
}
});
});
});
})(window.jQuery);
<a href="${pageContext.request.contextPath}/galery/bikes/products/bike.jsp?id=${bike.id}&model=${bike.model}&smodel=${bike.smodel}">
при помощи Servlet, JSP
Спасибо, я посмотрю ту библиотеку.