У меня есть следующая переменная, которая обычно отправляется на следующий веб-метод.
data: "{item:" + JSON.stringify(json) + ",step:" + JSON.stringify(john) + " }",
Веб-метод:
[WebMethod(EnableSession = true)]
public static string GetCart(string item, string step)
{
HttpContext.Current.Session["f"] = item;
HttpContext.Current.Session["l"] = step;
return item;
}
Когда я пытаюсь добавить следующую переменную, третья переменная (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'
Вам нужны двойные кавычки:
...
data: "{\"item\":" + JSON.stringify(json) + ",\"mytest\":" + JSON.stringify(json) + ",\"step\":" + JSON.stringify(john) + " }"
...
В качестве альтернативы вы можете выполнить однократное выполнение:
...
data: JSON.stringify({item: json, mytest: json, step: john })
...