0
点赞
收藏
分享

微信扫一扫

Asp.Net中通过Ajax(post)双向传参实例(aspx经典版,源码实例,已测试!菜鸟必看!)


一、ajax.aspx.cs 后台代码。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Script.Services;
using System.Web.Services;


public partial class Time_ajax : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}

[WebMethod]
public static string ajax(string aaa, string bbb)
{
return aaa+bbb;
}

二、前台JS代码

$.ajax({
type: "Post",
url: "ajax.aspx/ajax",
data: "{'aaa':'电话号码:','bbb':'114'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
alert(data.d);
},
error: function (err) {
alert(err);
}
});






举报

相关推荐

0 条评论