Click here to Skip to main content
15,114,611 members
Home / Discussions / Web Development
   

Web Development

 
GeneralRe: Handlings rows in Datatables Pin
adekunbi30-Oct-14 0:40
Memberadekunbi30-Oct-14 0:40 
QuestionRe: Handlings rows in Datatables Pin
ZurdoDev30-Oct-14 2:37
professionalZurdoDev30-Oct-14 2:37 
AnswerRe: Handlings rows in Datatables Pin
adekunbi30-Oct-14 2:41
Memberadekunbi30-Oct-14 2:41 
GeneralRe: Handlings rows in Datatables Pin
ZurdoDev30-Oct-14 2:52
professionalZurdoDev30-Oct-14 2:52 
GeneralRe: Handlings rows in Datatables Pin
adekunbi30-Oct-14 3:02
Memberadekunbi30-Oct-14 3:02 
AnswerRe: Handlings rows in Datatables Pin
ZurdoDev30-Oct-14 3:12
professionalZurdoDev30-Oct-14 3:12 
GeneralRe: Handlings rows in Datatables Pin
adekunbi30-Oct-14 0:57
Memberadekunbi30-Oct-14 0:57 
QuestionTypeError: $(...).autocomplete is not a function Pin
NarVish24-Oct-14 1:20
MemberNarVish24-Oct-14 1:20 
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.

HTML
@model MvcApplication1.Models.UserProfile

@{
    ViewBag.Title = "UserProfile";
}
 
<form method="post"> 
    <input type="text" name="userName" />
    <input type="submit" value="Search By Name" />
</form>

<div id="restaurantList">
    @foreach (var item in ViewBag.users)
    {
        <div>
            <h4>@item.UserName</h4>
            <div>
                @item.Country
            </div>
            <div>
                Mail: @item.Email
            </div>
            <hr />
        </div>
    }
</div>

 <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:

C#
 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<Models.UserProfile>();
            UserProfile user;
            while (reader.Read())
            {
                user = new UserProfile();
                user.UserName = reader.GetString(0);
                user.Country = reader.GetString(1);
                user.Email = reader.GetString(2); 
                _db.UserProfiles.Add(user);
            } 
            var model =
                _db.UserProfiles
                   .OrderByDescending(r => r.UserName)
                   .Where(r => userName == null || r.UserName.StartsWith(userName));
                            ViewBag.users = model;
            return View();
        }

        public JsonResult AutoCompleteName(string term)
        {
            var result = (from r in _db.UserProfiles
                          where r.UserName.ToLower().Contains(term.ToLower())
                          select new { r.UserName }).Distinct();
            return Json(result, JsonRequestBehavior.AllowGet);
        }

SuggestionRe: TypeError: $(...).autocomplete is not a function Pin
Laiju k24-Oct-14 1:39
professionalLaiju k24-Oct-14 1:39 
GeneralRe: TypeError: $(...).autocomplete is not a function Pin
NarVish24-Oct-14 1:46
MemberNarVish24-Oct-14 1:46 
AnswerRe: TypeError: $(...).autocomplete is not a function Pin
Laiju k24-Oct-14 2:18
professionalLaiju k24-Oct-14 2:18 
GeneralRe: TypeError: $(...).autocomplete is not a function Pin
NarVish24-Oct-14 3:01
MemberNarVish24-Oct-14 3:01 
GeneralRe: TypeError: $(...).autocomplete is not a function Pin
Laiju k24-Oct-14 3:13
professionalLaiju k24-Oct-14 3:13 
AnswerRe: TypeError: $(...).autocomplete is not a function Pin
CAReed25-Oct-14 5:50
professionalCAReed25-Oct-14 5:50 
RantHTML & JavaScript pains Pin
Adriaan Davel19-Oct-14 8:05
MemberAdriaan Davel19-Oct-14 8:05 
QuestionHow to make my own hotspot Pin
Jassim Rahma18-Oct-14 14:17
MemberJassim Rahma18-Oct-14 14:17 
Questiondreamweaver help Pin
nikunj0117-Oct-14 20:23
Membernikunj0117-Oct-14 20:23 
AnswerRe: dreamweaver help Pin
Kornfeld Eliyahu Peter18-Oct-14 22:09
professionalKornfeld Eliyahu Peter18-Oct-14 22:09 
QuestionA good free wysiwyg IDE for web applications linked to XML Native Databases Pin
Member 1116159717-Oct-14 8:25
MemberMember 1116159717-Oct-14 8:25 
AnswerRe: A good free wysiwyg IDE for web applications linked to XML Native Databases Pin
Kornfeld Eliyahu Peter18-Oct-14 22:08
professionalKornfeld Eliyahu Peter18-Oct-14 22:08 
SuggestionUnable to integrate EBS PAYMENT GATEWAY in my wordpress's site Pin
Member 1066291216-Oct-14 22:50
MemberMember 1066291216-Oct-14 22:50 
SuggestionRe: Unable to integrate EBS PAYMENT GATEWAY in my wordpress's site Pin
ZurdoDev17-Oct-14 3:11
professionalZurdoDev17-Oct-14 3:11 
GeneralRe: Unable to integrate EBS PAYMENT GATEWAY in my wordpress's site Pin
Simon_Whale17-Oct-14 5:05
professionalSimon_Whale17-Oct-14 5:05 
QuestionHow to replicate list boxes across a Web page? Pin
Member 876166714-Oct-14 14:28
MemberMember 876166714-Oct-14 14:28 
AnswerRe: How to replicate list boxes across a Web page? Pin
vbmike17-Oct-14 9:17
Membervbmike17-Oct-14 9:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.