TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Jes Sie
741
1.2k
281.8k
Autocomplete in html input using webservice
Mar 24 2017 2:47 AM
Can someone help me find the error in my code? I trying to make an autocomplete textbox. My code run in the other pages but in this particular page it gaves me an error. Here's the code snipet:
<script type=
"text/javascript"
>
$(document).ready(function () {
$(
".autosuggest"
).autocomplete({
source: function (request, response) {
$.ajax({
type:
"POST"
,
contentType:
"application/json;charset=utf-8"
,
url:
"AgentService.asmx/GetMatchingAgents"
,
data:
"{'agent':'"
+ document.getElementById('AgentNumber
').value + "'
}",
dataType:
"json"
,
success: function (data) {
response(data.d);
},
error: function (result) {
alert(
"Agent ID not found."
);
}
});
}
});
});
</script>
<body>
<form id=
"form1"
runat=
"server"
>
<div>
<fieldset style=
"width: 500px;"
class
=
"ui-widget"
>
<legend><strong>CI Issuance to Agents</strong></legend>
<table>
<tr>
<td>CI Series #:
</td>
<td>
<asp:TextBox ID=
"txtCISeries"
runat=
"server"
></asp:TextBox>
</td>
</tr>
<tr>
<td>Issued To:
</td>
<td>
<input id=
"AgentNumber"
runat=
"server"
type=
"text"
class
=
"autosuggest"
placeholder=
"Search agent name"
/>
</td>
public
class
AgentService : System.Web.Services.WebService
{
[WebMethod]
public
List<
string
> GetMatchingAgents(
string
agent)
{
List<
string
> agents =
new
List<
string
>();
using
(SqlConnection con = DBConnection.GetDbCon())
{
SqlCommand cmd =
new
SqlCommand(
"spGetMatchingAgents"
, con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue(
"@AgentID"
, agent);
con.Open();
SqlDataReader rdr = cmd.ExecuteReader();
while
(rdr.Read())
{
agents.Add(rdr[
"AgentID"
].ToString());
}
}
return
agents;
}
}
The webservice is working fine. I tried it and got the data. But when i call it from the webform it gives me this error:
Reply
Answers (
3
)
How to Calculate XIRR return in one day transaction??
How to calculate CAGR in asp.net?