1
控制器代碼:的WebAPI傳遞的數據是空
[HttpPost]
public void UpdateClient(Client client)
{
// Rest of code
}
客戶端代碼:
$.ajax({
url: "api/client/UpdateClient",
type: 'post',
contentType: 'application/json',
data: "{client: " + ko.toJSON(model.selectedClient()) + "}",
success: function (result) {
getClients();
$("#loader").hide();
},
failure: function (result) {
alert(result.d);
$("#loader").hide();
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
alert("An error occurred, please try again.");
$("#loader").hide();
}
});
無論出於何種原因,參數「客戶」始終是空儘管檢查model.selectedClient()是確定和ko.toJSON正在工作。
完美,只是改變了那個伎倆。 – user1166905