onfocus和jQuery-困境

My question is what is better to use onfocus="ajaxUpdateCompanyList2();" in my input OR $("#CompanyNameFilter").focus(function(), I'm new to jquery, so I have quite some issues with code aswell.

JS code option 1:

$(document).ready(function() {
    $("#CompanyNameFilter").autocomplete("ajaxFuncs.php",{cacheLength:1,mustMatch:1,extraParams:{getClientList:1}});
});

    $("#CompanyNameFilter").focus(function() {
        var CN99 = $("#CompanyNameFilter").val();

        url: "clientsFiltering.php?companyname=" + CN99,
        method: "GET",
        success : function( data ) {
            var content = $(data).find("#companyList").html();
        }
    });

JS code option 2:

  $(document).ready(function() {
        $("#CompanyNameFilter").autocomplete("ajaxFuncs.php",{cacheLength:1,mustMatch:1,extraParams:{getClientList:1}});
    });

    $.fn.ajaxUpdateCompanyList2=function() {
        var CN99 = $("#CompanyNameFilter").val();

        url: "clientsFiltering.php?companyname=" + CN99,
        method: "GET",
        success : function( data ) {
            var content = $(data).find("#companyList").html();
        }
    };

html code option 1: It doesn't work at all :S

<input id="CompanyNameFilter" style="width: 205px;"/>

html code option 2: I get error like, ajaxUpdateCompanyList2 is undefined function :S

<input id="CompanyNameFilter" onfocus="ajaxUpdateCompanyList2();" style="width: 205px;"/>

If using jQuery 1.7+ something like this is the way to go:

$("#CompanyNameFilter").on('focus', function() {
   //code here
});

Inline JS is almost never the way to go!

Then again, you should probably start by reading the jQuery documentation, and figure out exactly what it is your trying to do, as the first code looks like it's missing an Ajax function, and the second code looks like some sort of attempt to create a plugin, also missing something essential?