Autocomplete with AJAX and JSON not working?

Autocomplete with AJAX and JSON not working?

I'm trying to fill an jQuery Autocomplete with JSON data from inside an Ajax function. This is what my script looks like:


$(function() {

$( "#autocomplete" ).autocomplete({
    source: function(request, response)
            url: "<?php echo $this->webroot; ?>portfolios/ajax_clients_dropdown/"+request.term+".json",
            dataType: "jsonp",
            data: {q:request.term},
            success: function(data)

            error: function(){console.log(request.term);}




his code run without any errors, but do not do anything when I type something in the search box. It's like the JSON isn't working, or the request isn't sending. 

This script is in my view file, and the url should point to a function in my controller. If I run the controller function in my browser, it returns JSON data correctly. I have a log function that runs as soon as the function is called. It records in the log when I run it directly in a browser, but doesn't record anything when I run the webpage normally(call the function from the view side).

Can someone please check it out?