62,073
社区成员
发帖
与我相关
我的任务
分享
/// <summary>
/// 此处ids
/// </summary>
/// <param name="ids">须与js传进来的data的键名称一致 类型应该也与js所对应的键值一致</param>
/// <returns>一般返回数据 以json字串为主 所以返回string</returns>
[WebMethod]
public static string GetArray(int[] ids,string[] strs)
{
return string.Join(",", ids)+ string.Join(",", strs);
}
$(function () {
let dataObj = {
"ids": [1, 2, 3, 6, 4, 5, 2, 4, 3],
"strs": ['csdn','gdyd','btsy']
}
$('#btn_sub').click(function () {
$.ajax({
url: 'ajaxArray.aspx/GetArray',
type: 'post',
data: JSON.stringify(dataObj),
contentType: "application/json; charset=utf-8",
dataType: 'json',
success: function (res) {
console.log(res)
},
error: function (error) {
console.log(error)
}
})
});
})
public class Person
{
public string Name { get; set; }
public string[] Phone { get; set; }
}