Код: Выделить всё
Name :
$(document).ready(function () {
$("#btnSave").click(function () {
var name = $("#txtInput").val();
console.log(JSON.stringify({ name: name }));
$.ajax({
type: "POST",
url: "Test.aspx/SaveData",
data: JSON.stringify({ name: name }),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
alert(response);
},
failure: function (response) {
alert("Error: " + response);
}
});
});
});
Код: Выделить всё
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static string SaveData(string name)
{
// process
return name;
}
Есть идеи?
Подробнее здесь: https://stackoverflow.com/questions/798 ... ode-behind