次のWebメソッドに通常どおり投稿する次の変数があります。
data: "{item:" + JSON.stringify(json) + ",step:" + JSON.stringify(john) + " }",
Web メソッド:
[WebMethod(EnableSession = true)]
public static string GetCart(string item, string step)
{
HttpContext.Current.Session["f"] = item;
HttpContext.Current.Session["l"] = step;
return item;
}
次の変数を追加しようとすると、3 番目の変数 (mytest) が投稿されません
data: "{item:" + JSON.stringify(json) + ",mytest:" + JSON.stringify(json) + ",step:" + JSON.stringify(john) + " }",
ウェブ方式
[WebMethod(EnableSession = true)]
public static string GetCart(string item, string step, string mytest)
{
HttpContext.Current.Session["f"] = item;
HttpContext.Current.Session["l"] = step;
HttpContext.Current.Session["mytest"] = mytest;
return item;
}
編集
そしてポストステートメント
$.ajax({
type: 'POST',
url: "mypage.aspx/GetCart",
data: "{item:" + JSON.stringify(json) + ",mytest:" + JSON.stringify(json) + ",step:" + JSON.stringify(john) + " }",
contentType: 'application/json; charset=utf-8',
dataType: 'json'