【发布时间】:2016-06-08 10:04:19
【问题描述】:
我有一个包含多个循环生成的文本区域的视图。我想使用 jQuery 在表单提交上传递值。我使用下面的代码来调用动作结果:
var url = "/Template/DATA";
var form = $('<form action="' + url + '" method="post">' +
'<input type="text" name="TemplateID" value="' + TemplateID + '" />' +
'<input type="text" name="SectionID" value="' + SectionID + '" />' +
'<input type="text" name="StartDate" value="' + StartDate + '" />' +
'<input type="text" name="EndDate" value="' + EndDate + '" />' +
// here i want to pass the values of the text areas to the action result
'</form>');
$('body').append(form);
form.submit();
【问题讨论】:
-
看起来您最好使用 AJAX 而不是动态构建表单的 HTML,将其附加到 DOM 并立即提交。
-
视图的模型是什么?
标签: jquery asp.net-mvc asp.net-mvc-4 c#-4.0