Jquery autocomplete webservices - what am i doing wrong??
Posted
by dzajdol
on Stack Overflow
See other posts from Stack Overflow
or by dzajdol
Published on 2010-04-14T08:18:40Z
Indexed on
2010/04/14
8:23 UTC
Read the original article
Hit count: 359
I created a class for JSON responses:
public class PostCodeJson
{
public String Text { get; private set; }
public String Value { get; private set; }
#region Constructors
/// <summary>
/// Empty constructor
/// </summary>
public PostCodeJson()
{
this.Text = String.Empty;
this.Value = String.Empty;
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="_text"></param>
/// <param name="_value"></param>
public PostCodeJson(String _text, String _value)
{
this.Text = _text;
this.Value = _value;
}
#endregion Constructors
}
and function returns list of this class using in webservices method:
[WebMethod]
public List<PostCodeJson> GetPostCodesCompletionListJson(String prefixText, Int32 count)
{
return LibDataAccess.DBServices.PostCodes.GetPostCodeJson(prefixText, count);
}
And in aspx i do this that:
<script>
$(document).ready(function() {
$("#<%=pc.ClientID %>").autocomplete(
baseUrl + "WebServices/Autocomplete.asmx/GetPostCodesCompletionListJson",
{
parse: function(data) {
var array = new Array();
for (var i = 0; i < data.length; i++) {
var datum = data[i];
var name = datum.Text;
var display = name;
array[array.length] = { data: datum, value: display, result: datum.Value };
}
return array;
},
dataType: "xml"
});
});
</script>
and when you enter something in the box i got an error: Request format is unrecognized for URL unexpectedly ending in '/GetPostCodesCompletionListJson
What am I doing wrong??
© Stack Overflow or respective owner