1
Answer

jquey autocompletion , method is not calling method

aditya immadi

aditya immadi

8y
179
1
Hai all
 
i tried below code for jq autocompletion .but it will call my webservice method and jumps for error...
 
$(document).ready(function () {
// var v = $('#txtsearch').val();
$("#txtsearch").autocomplete({
source: function (request, response) {
$.ajax({
type: "GET",
contentType: "application/json",
url: "Default2.aspx/GetCourseNames",
data: "{'Course': '" + $('#txtsearch').val() + "'}",
//'" + document.getElementById('txtsearch').value + "'
dataType: "json",
success: function (data) {
response(data.d);
},
error: function (result) {
alert("Error......");
}
});
}
});
and my .cs page is
 
[System.Web.Services.WebMethod]
public List<string> GetCourseNames(string Course)
{
List<string> result = new List<string>();
string s = ConfigurationManager.ConnectionStrings["con"].ConnectionString;
SqlConnection con = new SqlConnection(s);
SqlCommand cmd = new SqlCommand("Sp_Search", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@CName", Course);
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
if (dr.HasRows)
{
result.Add(dr["CourseName"].ToString());
}
return result;
 
i thought eveything is fine ....but it always jumps to error block while i m trying to enter text
 
any help
 
TIA 
Answers (1)