我的觀點包含這樣一種形式:與更新的div郵政的表單數據控制器
@model WebApplication1.Models.Books
<form action="/Test/Run" method="POST">
<table>
<tr>
<td>
Name: @Html.TextBoxFor(m => m.Title)
</td>
</tr>
<tr>
<td>
<input type="button" id="getbooksbutton" value="Get Books From Person"/>
</td>
<td>
<div id="books"></div>
</td>
</tr>
<tr>
<td>
<input type="submit" value="Send Data"/>
</td>
</tr>
</table>
</form>
我的模型:
public class Books
{
public string Title { get; set; }
public List<BooksDetails> BooksData { get; set; }
}
和
public class BooksDetails
{
public string BookVersion { get; set; }
public string BookPrice { get; set; }
}
我正在做一個ajax調用我的控制器getbooksbutton點擊參數「標題」,它返回並更新div「書籍」更多的詳細信息爲本書給出的名稱成功。
股利獲取我的AJAX功能這樣的更新:
var div = $("#books");
$.each(data.BooksData, function(i, item) {
div.append("<br/>" + "Book Version: " + item.BookVersion + ", Set your Price: " + "<input type=\"text\" name=\"item.BookPrice\" value=\"0\">");
});
用戶應該能夠設定一個價格爲每本書,這就是爲什麼我追加輸入字段時, div得到更新。
當用戶點擊「最終」提交按鈕時,我想通過更新的BooksData對象將圖書對象發佈到我的控制器。
我看了很多例子,但我沒有找到如何工作。
將您的人物對象發佈代碼。 –