Can't send data using AJAX

Thank you, it looks like it should work but where do I add this bit:

{
    if(!$('#container').hasClass('is-loaded')) {
    $('#container').addClass('is-loaded');
    $('#container').html(data);
} else {
    $('#container').append(data);
}
     }

Every time I try I get a syntax error.

Also the output should actually be http://localhost/filter/?search=Berry was I trying to get http://localhost/filter/?search=Berry&flavour=Berry? I’m pretty new to this so am still learning as I go