I'm a newbie in this, I'm trying to refresh a menu value (cart content) without reloading the whole page.
This is my issue : ${cartSession.getCartContent()} value in the alert check is Undefinied.
If it could help, In server side I'm using Spring.
$(document).ready(function(){
var $form = $("#panierform");
$form.submit(function(){
$.post($(this).attr('action'), $(this).serialize(), function(response){
},'json');
alert("Ajouté avec succès !");
refreshCartValue();
return false;
});
});
function refreshCartValue() {
alert(${cartSession.getCartContent()});
$("#cartValue").text("");
$("#cartValue").text(${cartSession.getCartContent()});
}
${cartSession.getCartContent()}can only execute on the server, therefore it will only ever contain the value that was originally returned with the current page. You'll need to instead return that value from the server when you perform the ajax request, then access it within the success of that ajax request.