Click here to Skip to main content
15,867,989 members
Home / Discussions / Web Development
   

Web Development

 
GeneralRe: Handlings rows in Datatables Pin
adekunbi29-Oct-14 23:40
adekunbi29-Oct-14 23:40 
QuestionRe: Handlings rows in Datatables Pin
ZurdoDev30-Oct-14 1:37
professionalZurdoDev30-Oct-14 1:37 
AnswerRe: Handlings rows in Datatables Pin
adekunbi30-Oct-14 1:41
adekunbi30-Oct-14 1:41 
GeneralRe: Handlings rows in Datatables Pin
ZurdoDev30-Oct-14 1:52
professionalZurdoDev30-Oct-14 1:52 
GeneralRe: Handlings rows in Datatables Pin
adekunbi30-Oct-14 2:02
adekunbi30-Oct-14 2:02 
AnswerRe: Handlings rows in Datatables Pin
ZurdoDev30-Oct-14 2:12
professionalZurdoDev30-Oct-14 2:12 
GeneralRe: Handlings rows in Datatables Pin
adekunbi29-Oct-14 23:57
adekunbi29-Oct-14 23:57 
QuestionTypeError: $(...).autocomplete is not a function Pin
NarVish24-Oct-14 0:20
NarVish24-Oct-14 0: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 0:39
professionalLaiju k24-Oct-14 0:39 
GeneralRe: TypeError: $(...).autocomplete is not a function Pin
NarVish24-Oct-14 0:46
NarVish24-Oct-14 0:46 
AnswerRe: TypeError: $(...).autocomplete is not a function Pin
Laiju k24-Oct-14 1:18
professionalLaiju k24-Oct-14 1:18 
GeneralRe: TypeError: $(...).autocomplete is not a function Pin
NarVish24-Oct-14 2:01
NarVish24-Oct-14 2:01 
GeneralRe: TypeError: $(...).autocomplete is not a function Pin
Laiju k24-Oct-14 2:13
professionalLaiju k24-Oct-14 2:13 
AnswerRe: TypeError: $(...).autocomplete is not a function Pin
CAReed25-Oct-14 4:50
professionalCAReed25-Oct-14 4:50 
RantHTML & JavaScript pains Pin
Adriaan Davel19-Oct-14 7:05
Adriaan Davel19-Oct-14 7:05 
QuestionHow to make my own hotspot Pin
Jassim Rahma18-Oct-14 13:17
Jassim Rahma18-Oct-14 13:17 
Questiondreamweaver help Pin
nikunj0117-Oct-14 19:23
nikunj0117-Oct-14 19:23 
AnswerRe: dreamweaver help Pin
Kornfeld Eliyahu Peter18-Oct-14 21:09
professionalKornfeld Eliyahu Peter18-Oct-14 21:09 
QuestionA good free wysiwyg IDE for web applications linked to XML Native Databases Pin
Member 1116159717-Oct-14 7:25
Member 1116159717-Oct-14 7:25 
AnswerRe: A good free wysiwyg IDE for web applications linked to XML Native Databases Pin
Kornfeld Eliyahu Peter18-Oct-14 21:08
professionalKornfeld Eliyahu Peter18-Oct-14 21:08 
SuggestionUnable to integrate EBS PAYMENT GATEWAY in my wordpress's site Pin
Member 1066291216-Oct-14 21:50
Member 1066291216-Oct-14 21:50 
SuggestionRe: Unable to integrate EBS PAYMENT GATEWAY in my wordpress's site Pin
ZurdoDev17-Oct-14 2:11
professionalZurdoDev17-Oct-14 2:11 
GeneralRe: Unable to integrate EBS PAYMENT GATEWAY in my wordpress's site Pin
Simon_Whale17-Oct-14 4:05
Simon_Whale17-Oct-14 4:05 
QuestionHow to replicate list boxes across a Web page? Pin
Member 876166714-Oct-14 13:28
Member 876166714-Oct-14 13:28 
AnswerRe: How to replicate list boxes across a Web page? Pin
vbmike17-Oct-14 8:17
vbmike17-Oct-14 8: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.