weixin_33676492 2015-10-01 03:51 采纳率: 0%
浏览 24

Ajax数组列表传递

Im trying to pass multiple array list in one ajax call. Can someone please help me?

Array

var arraylist = [{name: name1, age: age1}, {name: name2, age: age2}, ...]

ajax

$.ajax({
        url: "api/postProductLink",
        contentType: "application/json",
        type: "POST",
        data: { Info: arraylist},
        dataType: "json",
        success: function (result) {

        }
    });

backend vb.net

<HttpPost>
<POST("api/postProductLink")> _
Public Function postProductLink(data As ProductMerchandiseModel) As ResponseCallBack
    'code here
End Function

model

Public Class ProductMerchandiseModel
Public name As String
Public age As Integer End Class

I want to individually pull each name and age.

Thanks!

  • 写回答

1条回答 默认 最新

  • elliott.david 2015-10-01 06:36
    关注

    Your AJAX call should look like this:

    $.ajax({
        url: "api/postProductLink",
        contentType: "application/json",
        type: "POST",
        data: JSON.stringify(arrayList),// Since your contentType is JSON.
        dataType: "json",
        success: function (result) {
    
        }
    });
    
    评论

报告相同问题?