を使用して、10 億回行ったようにASP.NET MVC 3
、jQuery ( ) AJAX 呼び出しを行っています。ver 1.7.1
しかし、私は奇妙なことに気づきました。次の呼び出しは正常に機能します。
// license object
var license = {
City: "New York",
CompanyID: 1,
County: "N/A",
IsActive: true
};
// make the request
var $req = $.post('/License/theLicense', license);
$req.success(function () {
// this works!
});
[HttpPost]
public void Save(License theLicense)
{
// save
}
ただし、コントローラーのデータパラメーターを指定すると、コントローラーに登録されません
// license object
var license = {
City: "New York",
CompanyID: 1,
County: "N/A",
IsActive: true
};
// make the request
// this time the controller parameter is specified
// the object will be blank at the server
var $req = $.post('/License/theLicense', { theLicense: license });
$req.success(function () {
// this does not work
});
以下に示すように、オブジェクトはコントローラーで空白です
別のデータパラメーターを渡す必要があるため、これは面倒ですが、この問題のためにできません。
注: JSON は POCO と同じです。
data パラメーターを指定すると、オブジェクトがコントローラーで空白に表示されるのはなぜですか?