Я столкнулся с проблемой здесь, я действительно не мог найти способ вырезать значения моего следующего объекта JSON в веб-методе
Код ASPX
$(document).ready(function () {
// Add the page method call as an onclick handler for the div.
$("#Button1").click(function () {
$.ajax({
type: "POST",
url: "Default.aspx/MethodCall",
data: '{
"Call": '{"Type": "U", "Params": [{"Name": "John", "Position": "CTO"}]}}', contentType: "application / json;charset = utf-8 ", dataType:" json ", кеш: true,
success: function (msg) {
// Replace the div's content with the page method's return.
$("#Result").text(msg.d);
},
error: function (xhr, status, error) {
// Display a generic error for now.
var err = eval("(" + xhr.responseText + ")");
alert(err.Message);
}
});
});
});
ASPX.CS Code
[WebMethod]
public static string MethodCall(JObject Call)
{
return "Type of call :"+ Call.Type + "Name is :" + Call.Params.Name + "Position is :"
Call.Params.Position ;
}
, большое спасибо за продвинутый уровень.