Expected '}' error - jQuery UI Autocomplete

Expected '}' error - jQuery UI Autocomplete

Hi,

I am trying to use the auto complete option in jQuery UI for SharePoint OnPremise. I have tried the below code:

  1.  $("input[title='Skill Required Field']").autocomplete({
        source: function (request, response) {
        var term = request.term;
        var listname = "MySkills";
        var resurl = siteURL + "/_api/web/lists/getbytitle('" + listname + "')/items?$select=Title&$filter=startswith(Title,'" + term + "')";
        var alldata = [];
         $.ajax({
           url: resurl,
           method: "GET",
           headers: { "Accept": "application/json; odata=verbose" },
           success: function (data) {   
            var items = data.d.results;
            
             if(items.length > 0){
              alldata.push(items);
             }
              response(alldata);
           },
           error: function (data) {
            console.log(data.responseText);  
           }
          });
      
         }
  2.        });
  3. I am getting the error as - Syntax error. Expected '}' . I am not sure, which of the parenthesis is missing.
  4. How to fix this?
  5. Thanks