现在的位置: 首页 > 综合 > 正文

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

2012年11月12日 ⁄ 综合 ⁄ 共 532字 ⁄ 字号 评论关闭

服务端:

应用命名空间

 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("处理失败");
            }
        });

抱歉!评论已关闭.