获取服务端页面JSON数据的JQUERY ajax方法定义

服务端:

应用命名空间

 using System.Web.Services;

using System.Web.Script.Services;

 

代码:

[WebMethod(EnableSession=true)]
[ScriptMethod(UseHttpGet=false)]
public static string GetAllRecord()
{
  //代码内容
}

 客户端:

 

$.ajax({
            type: "POST",
            contentType: "application/json",
            url: "Default.aspx/MethodName",
            data: "{}",
            dataType: "json",
            success: function(data) {
            var result = eval(data.d);
            },
            error: function() {
                alert("处理失败");
            }
        });

posted on 2012-02-01 16:38  刑天  阅读(316)  评论(0编辑  收藏  举报

导航