taki kod mam:
$(document).ready(function () { var sessionCart = []; {% else %} var sessionCart = {{ sessionCart|raw }}; {% endif %} var cart = kendo.observable({ contents: sessionCart, updateSessionCart: function () { $.ajax({ type: 'POST', url: '{{ path('session_cart_update') }}', dataType: 'json', data: {'cart': JSON.stringify(this.contents)}, }); }, getSessionCart: function () { $.ajax({ type: 'GET', url: '{{ path('get_session_cart') }}', dataType: 'json', success: function (data) { this.contents = data; }, }); }, add: function (item) { this.getSessionCart(); console.log('this.contents ' + JSON.stringify(this.contents));//TU WARTOŚĆ JEST STARA }
Problem polega na tym że console.log z ostatniego wiersza zwraca starą wartość, nie nową.