Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  5] [ 4]  / answers: 1 / hits: 10330  / 11 Years ago, fri, january 10, 2014, 12:00:00

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()});
}

More From » jquery

 Answers
8
 alert(${cartSession.getCartContent()});


You can't call a server side Java method from Javascript.



Javascript executes on the client browser, Java on the server.



What you can do is handle form posting VIA Ajax. Make a POST request to server, return the actual response(with success/failure flags) and do whatever you want with it via JQuery/Javscript:



Follow this simple example with Spring:
http://www.raistudies.com/spring/spring-mvc/ajax-spring-mvc-3-annonations-jquery/


[#48798] Thursday, January 9, 2014, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
andreguym

Total Points: 125
Total Questions: 112
Total Answers: 103

Location: Wallis and Futuna
Member since Tue, Mar 30, 2021
3 Years ago
;