I wrote the following webservice asmx file in my website:
[WebService(Namespace = "http://eumcore.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
public class jsonTest : System.Web.Services.WebService {
public jsonTest () {
}
[WebMethod(Description = "Gets the names matching part of a title.")]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public void getName() {
List<nameEntry> nameList = new List<nameEntry>();
nameList.Add(new nameEntry() {id="1", name="John"});
nameList.Add(new nameEntry() { id = "3", name = "Alex" });
this.Context.Response.ContentType = "application/json; charset=utf-8";
JavaScriptSerializer js = new JavaScriptSerializer();
string strJSON = js.Serialize(nameList);
this.Context.Response.Write(strJSON);
}
}
As a start I wanted it to return the same array each time, the result of the webservice when i call it directly is:
[{"id":"1","name":"John"},{"id":"3","name":"Alex"}]
Which is the correct reply, when i use it as a local input the result is fine but when i call the webservice in the input method of tokeninput (I assigned an error message to the function) i get the following error: "200 parsererror undefined"
Could anyone help me figure it out?
Thanks
Doron
EDIT: after playing around with jquery code a bit i managed to receive the data but i get the following error:
200
parsererror
[{"id":"1","name":"aaA"},{"id":"3","name":"aaA"}]{"d":null}
What I don't understand is what is d and why is it null?
when i call the webservice in the input method of tokeninputmean?$("#demo-input").tokenInput("/names/jsonTest.asmx/getName");