通过AJAX将多维数组传递给Web API

时间:2014-06-04 14:28:31

标签: jquery asp.net ajax asp.net-web-api

我创建了一个数组:

var p = Array();
var obj = {};
obj.resId = RequestData.Table[i].shID;
obj.nesId = RequestData.Table[i].bkid;
obj.BlockRequest = req;
obj.BlockApprove = 0;
obj.MarketingID = i;
obj.UserID = i;
obj.Notes = "";
obj.Operation = "test";
p.push(obj);

并尝试通过AJAX将其发送到Web API控制器:

var request = $.ajax({
    url: "testcontroller/testfunction",
    type: 'POST',
    data: JSON.stringify(p),
    dataType: 'json',
    accepts: {
        json: "application/json"
    },
    success: function (response) {

    },
    error: function (xhr, ajaxOptions, thrownError) {
        //debugger;
        alert('failure');
    },
    complete: function () {
    }
});

我的控制器看起来像这样:

<HttpGet()>
Public Function testfunction(ByVal p As List(Of dataclass)) As DataSet
End Function

我无法访问Web API中的控制器中的数据(在数组p中)。有什么想法吗?

0 个答案:

没有答案