我有一个 Twig 模板,我想在{{ item.getPrice() }}它完成加载后附加商品的价格。我正在考虑使用 AJAX 在 jQuery 中执行此操作,但我不知道如何将变量分配给url值以及如何分配{{ item.getPrice() }}给变量offerPrice。
$.ajax ({
url: {{ item.getPrice() | json_encode | raw }}
}).done( function() {
$('#price').append(offerPrice);
});