connersz
connersz

Reputation: 1213

Object doesn't support property or method 'autocomplete'

I am getting this error after adding some autocomplete code. I am sure it has something to do with duplicate jQuery references after searching online but I have it referenced only once.

The application uses a master page but the page in question doesn't use it so I have jquery referenced in both.

$(".autosuggest").autocomplete({
  source: function(request, response) {
    $.ajax({
      type: "POST",
      contentType: "application/json; charset=utf-8",
      url: "CustomerTypes.aspx/GetAutoCompleteData",
      data: "{'Customer':'" + document.getElementById('txtCustomerType').value + "'}",
      dataType: "json",
      success: function(data) {
        response(data.d);
      },
      error: function(result) {
        alert("Error");
      }
    });
  }
});

Upvotes: 3

Views: 19033

Answers (2)

Rory McCrossan
Rory McCrossan

Reputation: 337560

autocomplete() is a method in the jQueryUI library. You need to add a reference to that as well as jQuery.js:

<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.0/themes/smoothness/jquery-ui.css" />
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.0/jquery-ui.min.js"></script>

Upvotes: 7

Jai
Jai

Reputation: 74738

You have to add this library after jquery:

<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>

Upvotes: 4

Related Questions