![](/img/trans.png)
[英]How send complex data type with ajax to the action in controller in ASP.NET MVC
[英]asp.net how to access ajax call data in the controller action
如您在下面的示例中所看到的,我使用data屬性將data:傳遞給控制器動作,如何在動作中訪問這些數據,我使用了request ['data'],但沒有成功
<script>
$('#btnSelected').on('click', function (e) {
var selectedIDs = [];
$("#myTable tr.selected").each(function (index, row) {
selectedIDs.push($(row).find("td:first").html());
});
var selecteddata =selectedIDs
var link = '@Url.Action("ConvertApplication", "Applications")';
$.ajax({
url: link,
type: 'POST',
data: selecteddata ,
contentType: 'application/html',
success: function (content) {
$('#ConvertToProject').html(content);
},
error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
}
});
});
</script>
您的操作應具有一個列表作為輸入參數。
Public ActionResult ConvertApplication(List<int> selecteddata)
{
...
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.