I have created a c# webservice and i am trying to call it and consume it from a javascript script, what is the way or the best way to do it, thanks in advance.
I’ll explain more:
this is the web service:
public class DocumentInfo : System.Web.Services.WebService
{
[WebMethod(EnableSession = true)]
[ScriptMethod(ResponseFormat = System.Web.Script.Services.ResponseFormat.Json)]
public string GetDocumentInfo(string id)
{
Document document = new Document(Int32.Parse(id));
string output = JsonConvert.SerializeObject(document);
return output;
}
}
I have tested it, it works, when i tried the suggested ajax solutions, i got this error 500 Internal Server Error.
Read some of the tutorials
http://encosia.com/using-jquery-to-consume-aspnet-json-web-services/
http://weblogs.asp.net/jalpeshpvadgama/archive/2010/08/29/calling-an-asp-net-web-service-from-jquery.aspx