您不需要数组-您需要一个简单的JS对象(映射到字典)。此代码应工作:
var things = {};things['1'] = 10;things['2'] = 11;$.ajax({ url: '/api/DoStuff?id=' + id, data: JSON.stringify(things), contentType: 'application/json' type: 'POST', dataType: 'json'});
您不需要数组-您需要一个简单的JS对象(映射到字典)。此代码应工作:
var things = {};things['1'] = 10;things['2'] = 11;$.ajax({ url: '/api/DoStuff?id=' + id, data: JSON.stringify(things), contentType: 'application/json' type: 'POST', dataType: 'json'});