Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. TypeError: $(...).autocomplete is not a function

TypeError: $(...).autocomplete is not a function

Scheduled Pinned Locked Moved Web Development
javascripthelpcsswpfdesign
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    NarVish
    wrote on last edited by
    #1

    I'm trying to implement autocomplete feature for my search text box. Fire bug shows the error shown in subject. Please let me know my mistake. Please find my code below.

    @model MvcApplication1.Models.UserProfile

    @{
    ViewBag.Title = "UserProfile";
    }

    <form method="post">
    <input type="text" name="userName" />
    <input type="submit" value="Search By Name" />
    </form>

    @foreach (var item in ViewBag.users)
    {
    

    @item.UserName

                @item.Country
            
    
            
    
                Mail: @item.Email
    

    }
    

    <script src="~/Scripts/jquery-1.8.2.min.js"></script>
    <script src="~/Scripts/jquery-ui-1.9.2.min.js"></script>
    @Styles.Render("~/Content/themes/base/css")

    <script type="text/javascript">
    $(document).ready(function () {

        $("#userName").autocomplete({
            source: function (request, response) {
                 
                $.ajax({
                    url: "~/Home/AutoCompleteName",
                    type: "POST",
                    dataType: "json",
                    data: { term: request.term },
                    success: function (data) {
                        response($.map(data, function (item) {
                            return { label: item.Country, value: item.Country };
                        }))
                    }
                })
            },
            messages: {
                noResults: "", results: ""
            }
        });
    })
    

    </script>

    Code in Controller:

    public ActionResult UserProfile(string userName = null)
    {
    string conString = "User Id=RDB; password=RDB; Data Source=172.18.164.146:1521/XE; Pooling=false;";

            OracleConnection con = new OracleConnection();
            con.ConnectionString = conString;
            con.Open();
    
            OracleCommand cmd = con.CreateCommand();
            cmd.CommandText = "select USR\_USERNAME, USR\_COUNTRY, USR\_EMAIL\_ADDR from OBRS\_USER";
    
            OracleDataReader reader = cmd.ExecuteReader();
            \_db.UserProfiles = new List();
            UserProfile user;
            while (reader.Read())
            {
                user = new UserProfile();
                user.UserName = reader.GetString(0);
                user.Coun
    
    L C 3 Replies Last reply
    0
    • N NarVish

      I'm trying to implement autocomplete feature for my search text box. Fire bug shows the error shown in subject. Please let me know my mistake. Please find my code below.

      @model MvcApplication1.Models.UserProfile

      @{
      ViewBag.Title = "UserProfile";
      }

      <form method="post">
      <input type="text" name="userName" />
      <input type="submit" value="Search By Name" />
      </form>

      @foreach (var item in ViewBag.users)
      {
      

      @item.UserName

                  @item.Country
              
      
              
      
                  Mail: @item.Email
      

      }
      

      <script src="~/Scripts/jquery-1.8.2.min.js"></script>
      <script src="~/Scripts/jquery-ui-1.9.2.min.js"></script>
      @Styles.Render("~/Content/themes/base/css")

      <script type="text/javascript">
      $(document).ready(function () {

          $("#userName").autocomplete({
              source: function (request, response) {
                   
                  $.ajax({
                      url: "~/Home/AutoCompleteName",
                      type: "POST",
                      dataType: "json",
                      data: { term: request.term },
                      success: function (data) {
                          response($.map(data, function (item) {
                              return { label: item.Country, value: item.Country };
                          }))
                      }
                  })
              },
              messages: {
                  noResults: "", results: ""
              }
          });
      })
      

      </script>

      Code in Controller:

      public ActionResult UserProfile(string userName = null)
      {
      string conString = "User Id=RDB; password=RDB; Data Source=172.18.164.146:1521/XE; Pooling=false;";

              OracleConnection con = new OracleConnection();
              con.ConnectionString = conString;
              con.Open();
      
              OracleCommand cmd = con.CreateCommand();
              cmd.CommandText = "select USR\_USERNAME, USR\_COUNTRY, USR\_EMAIL\_ADDR from OBRS\_USER";
      
              OracleDataReader reader = cmd.ExecuteReader();
              \_db.UserProfiles = new List();
              UserProfile user;
              while (reader.Read())
              {
                  user = new UserProfile();
                  user.UserName = reader.GetString(0);
                  user.Coun
      
      L Offline
      L Offline
      Laiju k
      wrote on last edited by
      #2

      Can you just try $(function () { instead of $(document).ready(function () {

      N 1 Reply Last reply
      0
      • L Laiju k

        Can you just try $(function () { instead of $(document).ready(function () {

        N Offline
        N Offline
        NarVish
        wrote on last edited by
        #3

        I tried, still it is giving same error

        $(function () {

            $("#userName").autocomplete({
                source: function (request, response) {
                     
                    $.ajax({
                        url: "~/Home/AutoCompleteName",
                        type: "POST",
                        dataType: "json",
                        data: { term: request.term },
                        success: function (data) {
                            response($.map(data, function (item) {
                                return { label: item.Country, value: item.Country };
                            }))
                        }
                    })
                },
                messages: {
                    noResults: "", results: ""
                }
            });
        })
        
        1 Reply Last reply
        0
        • N NarVish

          I'm trying to implement autocomplete feature for my search text box. Fire bug shows the error shown in subject. Please let me know my mistake. Please find my code below.

          @model MvcApplication1.Models.UserProfile

          @{
          ViewBag.Title = "UserProfile";
          }

          <form method="post">
          <input type="text" name="userName" />
          <input type="submit" value="Search By Name" />
          </form>

          @foreach (var item in ViewBag.users)
          {
          

          @item.UserName

                      @item.Country
                  
          
                  
          
                      Mail: @item.Email
          

          }
          

          <script src="~/Scripts/jquery-1.8.2.min.js"></script>
          <script src="~/Scripts/jquery-ui-1.9.2.min.js"></script>
          @Styles.Render("~/Content/themes/base/css")

          <script type="text/javascript">
          $(document).ready(function () {

              $("#userName").autocomplete({
                  source: function (request, response) {
                       
                      $.ajax({
                          url: "~/Home/AutoCompleteName",
                          type: "POST",
                          dataType: "json",
                          data: { term: request.term },
                          success: function (data) {
                              response($.map(data, function (item) {
                                  return { label: item.Country, value: item.Country };
                              }))
                          }
                      })
                  },
                  messages: {
                      noResults: "", results: ""
                  }
              });
          })
          

          </script>

          Code in Controller:

          public ActionResult UserProfile(string userName = null)
          {
          string conString = "User Id=RDB; password=RDB; Data Source=172.18.164.146:1521/XE; Pooling=false;";

                  OracleConnection con = new OracleConnection();
                  con.ConnectionString = conString;
                  con.Open();
          
                  OracleCommand cmd = con.CreateCommand();
                  cmd.CommandText = "select USR\_USERNAME, USR\_COUNTRY, USR\_EMAIL\_ADDR from OBRS\_USER";
          
                  OracleDataReader reader = cmd.ExecuteReader();
                  \_db.UserProfiles = new List();
                  UserProfile user;
                  while (reader.Read())
                  {
                      user = new UserProfile();
                      user.UserName = reader.GetString(0);
                      user.Coun
          
          L Offline
          L Offline
          Laiju k
          wrote on last edited by
          #4

          http://stackoverflow.com/questions/16300586/typeerror-autocomplete-is-not-a-function[^] Have you tried this

          N 1 Reply Last reply
          0
          • L Laiju k

            http://stackoverflow.com/questions/16300586/typeerror-autocomplete-is-not-a-function[^] Have you tried this

            N Offline
            N Offline
            NarVish
            wrote on last edited by
            #5

            yes. I googled and added scripts. but no use. I followed the code which is in below link http://www.itorian.com/2013/02/jquery-ui-autocomplete-with-json-in-mvc.html[^]

            L 1 Reply Last reply
            0
            • N NarVish

              yes. I googled and added scripts. but no use. I followed the code which is in below link http://www.itorian.com/2013/02/jquery-ui-autocomplete-with-json-in-mvc.html[^]

              L Offline
              L Offline
              Laiju k
              wrote on last edited by
              #6

              In the code he is using textbox in this format @Html.TextBox("Country") Have you tried like that

              1 Reply Last reply
              0
              • N NarVish

                I'm trying to implement autocomplete feature for my search text box. Fire bug shows the error shown in subject. Please let me know my mistake. Please find my code below.

                @model MvcApplication1.Models.UserProfile

                @{
                ViewBag.Title = "UserProfile";
                }

                <form method="post">
                <input type="text" name="userName" />
                <input type="submit" value="Search By Name" />
                </form>

                @foreach (var item in ViewBag.users)
                {
                

                @item.UserName

                            @item.Country
                        
                
                        
                
                            Mail: @item.Email
                

                }
                

                <script src="~/Scripts/jquery-1.8.2.min.js"></script>
                <script src="~/Scripts/jquery-ui-1.9.2.min.js"></script>
                @Styles.Render("~/Content/themes/base/css")

                <script type="text/javascript">
                $(document).ready(function () {

                    $("#userName").autocomplete({
                        source: function (request, response) {
                             
                            $.ajax({
                                url: "~/Home/AutoCompleteName",
                                type: "POST",
                                dataType: "json",
                                data: { term: request.term },
                                success: function (data) {
                                    response($.map(data, function (item) {
                                        return { label: item.Country, value: item.Country };
                                    }))
                                }
                            })
                        },
                        messages: {
                            noResults: "", results: ""
                        }
                    });
                })
                

                </script>

                Code in Controller:

                public ActionResult UserProfile(string userName = null)
                {
                string conString = "User Id=RDB; password=RDB; Data Source=172.18.164.146:1521/XE; Pooling=false;";

                        OracleConnection con = new OracleConnection();
                        con.ConnectionString = conString;
                        con.Open();
                
                        OracleCommand cmd = con.CreateCommand();
                        cmd.CommandText = "select USR\_USERNAME, USR\_COUNTRY, USR\_EMAIL\_ADDR from OBRS\_USER";
                
                        OracleDataReader reader = cmd.ExecuteReader();
                        \_db.UserProfiles = new List();
                        UserProfile user;
                        while (reader.Read())
                        {
                            user = new UserProfile();
                            user.UserName = reader.GetString(0);
                            user.Coun
                
                C Offline
                C Offline
                CAReed
                wrote on last edited by
                #7

                In your $.ajax call, change the type to "GET" and remove the data and success parameters. In your .cshtml file, set the method to "get" in your form. You do not need to pass any other data to the autocomplete function except for the form data.

                Christopher Reed "The oxen are slow, but the earth is patient."

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups