【发布时间】:2010-07-03 08:20:02
【问题描述】:
我在这里遇到了一个问题,我真的找不到能够在 Web 方法中删除我的以下 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: '{
“呼叫”:'{ “类型”:“U”, “参数”:[ { “姓名”:“约翰”, “职位”:“首席技术官” } ] } }', contentType: "应用程序/json; charset=utf-8", 数据类型:“json”, 缓存:真,
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 代码
[WebMethod]
public static string MethodCall(JObject Call)
{
return "Type of call :"+ Call.Type + "Name is :" + Call.Params.Name + "Position is :"
Call.Params.Position ;
}
非常感谢。
【问题讨论】:
标签: json asp.net-ajax