从webservice获取数据到jtemplates

时间:2013-02-13 18:01:32

标签: c# javascript asp.net jtemplates

我有一个我用C#和javascript打电话的网络服务。

从C#中我将一些项添加到Web服务中的List。 我通过

调用Web服务
static WebService source = new WebService();

并且在javascript中,使用jquery我尝试从列表中获取项目,但我不能...

    $.ajax({
    type: "POST",
    url: "WebService.asmx/GetList",
    data: "{}",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function (data) { alert(data.d) } });

是因为我调用静态?答案=是的,它将在asp.net和Web服务之间创建一个prectent存根。解决make:

public static List<String> StringsList = new List<String>();
[WebMethod]
public List<String> GetList() {
return StringsList;
}

并调用

WebService Source = new WebSource();

0 个答案:

没有答案