Index.html.twig
{% if amount.low != 0 %}
<p class="amount">{{ amount.low|round(0, 'floor') }}</p>
{% endif %}
Javascript:
$(document).ready(function () {
$("#Filter1").change(function() {
var input = $(this).val();
if(inputCPU.length >= 1) {
var data = {input: input};
$.ajax({
type: "POST",
url: ROOT_URL + "default/update/data",
dataType: 'json',
timeout: 3000,
success: function(response){
$(".amount").html(response.result); ???
console.log(response.result);
},
error: function() {
alert('Error with showing the filter.') //debug reasons
}
})
}
});
})
Controller:
public function updateDataAction(Request $request)
{
$amount = //db call
return ??
}
I'm a bit stuck on this code. I've a page where I show some data (amount), above there is a filter where users can manipulate the amount. How can I change the amount.low with the new filtered data when a filter is used? I'm stuck on what I should return in my controller and what the success whould be in my javascript.