Hi all
First of all I wana tell about my self,, im not a good coder you can say im newbie.

I have a problem with jQuery autocomplete.
I want to dispaly images in autocomplete.

Image path save in DB and physically every image is in different folder.

I have written some code fot that
I wana show my code so that you can easily understand what im doing wrong.

jQuery references

<link href="Styles/jquery-ui.min.css" rel="stylesheet" type="text/css" />

    <script src="js/jquery-1.10.2.js" type="text/javascript"></script>
    <script src="js/jquery-ui.min.js" type="text/javascript"></script>

HTML

<asp:TextBox ID="txtMovieName" runat="server" Width="80%" />
        <ul id="searchUl">

        </ul>

Script

<script type="text/javascript" language="javascript">
$(function () {
            $('#<%= txtMovieName.ClientID %>').autocomplete({
                source: function (request, response) {
                    $.ajax({
                        url: "GetMoviesService.asmx/GetMoviesName",
                        data: "{'MovieName': '" + request.term + "'}",
                        type: "POST",
                        dataType: "json",
                        contentType: "application/json;charset=utf-8",
                        success: function (data) {
                            response(data.d);
                        },
                        error: function (result) {
                            var errorMsg = "There is a problem processing your request !!";
                            alert(errorMsg);
                        }
                    });
                },
                create: function (event, ui) {
                    $(this).data('ui-autocomplete')._renderItem = function (ul, item) {
                        return $('<li>')
                    .append('<a>' + item.MovieName + '</a>' + '<br>')
                    .append("<img src=" + item.ImagePath + " alt='img' />")
                    .appendTo('#searchUl');
                    };
                }
            });
        });
    </script>

CS

public List<Movies> GetMoviesName(string MovieName)
    {
        List<Movies> MoviesName = new List<Movies>();
        string conStr = "Data Source=NOMEE-PC;Initial Catalog=My_Movies;Integrated Security=True";
        using (SqlConnection con = new SqlConnection(conStr))
        {

            string query = "Select * from Movies Where Movie_Name Like @MovieName + '%'";
            SqlCommand cmd = new SqlCommand(query, con);
            cmd.Parameters.AddWithValue("@MovieName", MovieName);
            con.Open();
            SqlDataReader dr = cmd.ExecuteReader();
            Movies movies = new Movies();
            while (dr.Read())
            {
                movies.MovieName = dr["Movie_Name"].ToString();
                movies.ImagePath = dr["Image_Path"].ToString();
                MoviesName.Add(movies);
            }
            return MoviesName;
        }
    }


    public class Movies
    {
        public int MovieID { get; set; }
        public string MovieName { get; set; }
        public int ReleaseYear { get; set; }
        public string ImagePath { get; set; }
    }

I'll be very thankful if someone sort this issue out.
thanx in advance

What happens access the page using your browser? use your dev tools (hit f12 in your browser). Any errors reported in your console? Any errors reported on the network tab (showing pages failing to load)?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.