webform ajax 请求后台方法

$.ajax({
    url: 'xxxx.aspx/GetString', //方法一定是静态的
    type: 'post',
    dataType: "json",
    contentType: "application/json; charset=utf-8",
    data: '{"key":"' + value + '"}', //一定是json字符串
    success: function (res) {
        //res: {"d":"value"} ,返回一个key为 d 的json
    }
})
[WebMethod]
public static string GetString(string key)
{
    //do something...
    return key;
}

猜你喜欢

转载自blog.csdn.net/csdn296/article/details/89229269
今日推荐