以下是我的部分观点 - 使用下面的 ajax 调用完成对控制器的调用
$.ajax(url, {
type: 'POST',
data: { Addresses: InboundAddresses },
cache: false,
crossDomain: true,
success: function (data) {
//Populate the form values
// Start Dialog Code
$myWindow = jQuery('#myDiv');
//instantiate the dialog
$myWindow.html(data);
$myWindow.dialog({
title: 'Select an address',
modal: true,
width: 'auto'
});
$myWindow.show();
$myWindow.dialog("open");
// End Dialog Code
$('#AddressTable').on('click', 'tr', function () {
// alert('You clicked row ' + ($(this).index()));
addAddress(InboundAddresses, Message, $(this).index())
});
},
error: function (jqXHR, textStatus, errorThrown) {
$('#Message').val('Kaboom!!! (The call blew up...#thatsucks)');
alert('The Dialog Box call failed...Sorry :(');
}
});
我跟踪了代码,调用正在正确发送内容(在提琴手中验证)控制器中的接收方法确实有对象,但这些对象中的内容为空。我认为这是一个解析问题。
请参阅下面的方法代码。
public PartialViewResult ShowAddresses(List<Address> Addresses)
{
ShowAddressViewModel viewModel = new ShowAddressViewModel();
viewModel.Addresses = Addresses;
viewModel.Message = "NEW";
return PartialView("_ShowAddress", viewModel);
}