是否可以将invalidTransferNo的数据获取到CSHTML文件?然后通过视图内部的模态。
无效的转账号码列表的全局变量。
public List<string> invalidTransferNo;
Controller.cs
[HttpPost]
public ActionResult SelectedTransferNoDeletion(List<string> selectedTransferNo, string deletionNotes) {
for (int i = 0; i < selectedTransferNo.Count; i++) {
var checkingTransferNo = deletePendingSrv.GetDeletionNotes(selectedTransferNo[i]);
if(checkingTransferNo.ToString().Equals("")) {
var output = deletePendingSrv.SaveDeletionPending(selectedTransferNo[i], SessionUserInfo.Username, deletionNotes);
}
else {
invalidTransferNo.Add(selectedTransferNo[i]);
}
}
return Json(BaseVariable.DEFAULT_SUCCESS);
}
脚本(CSHTML)
var selectedTransferNo;
$(".selectSaveButton").click(function () {
var deletionNotes = $('#selectedDeletionNotes').val();
$.ajax({
url: '/@Controller/SelectedTransferNoDeletion',
type: 'POST',
contentType:'application/json',
dataType: 'JSON',
data: JSON.stringify({ selectedTransferNo: selectedTransferNo, deletionNotes: deletionNotes }),
success: function (response) {
if (response != null) {
alert(response); -- getting the data here pass through a text box or list of invalid transfer.
}
},
error: function (response) {
alert(response);
}
});
});
我想从控制器到视图获取无效传输无列表的数据。可能吗?