.Net结合JQuery实现向aspx后台函数进行请求。

js部分:

$.ajax({
    url: "Default.aspx/aaaa",
    async: false,
    type: "POST",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    data: {name:"Tom",content:"hello"},
    success: function(data) {
        alert(data.d);
    },
    error: function() {
        alert("error!");
    }
});

 

cs部分:

using System.Web.Services;
using System.Web.Script.Services;

[WebMethod]
public static string aaaa(string name,string content)
{
    return name + ":" + content;
}

 

posted @ 2012-03-22 09:36  Jerome's Blog  阅读(1193)  评论(0编辑  收藏  举报