@lukasbestle is of course right, so your route should look like this:
c::set('routes', array(
array(
'pattern' => '(:all)/search',
'method' => 'GET',
'action' => function() {
$query = get('q');
$results = site()->search($query)->toJson();
return response::json(array(
$results
));
}
)
));
I’d also make the url more dynamic, so that you can move your site to a remote server without having to change the URL:
var url = window.location.href + "/search?q="+searchInput.val();
// ...
$.ajax({
// build the url
url: url,
context: jQuery('#wrapper-search-results')
})