我有一个表单,其中有一些字段.I想要显示一些标签,当用户输入一个文本框中的一个表单域的数字。我知道我必须使用Ajax,但问题是Ajax表单是另一种表单。因此,当我提交Ajax表单时,输出表单是submit,并且我无法获得Ajax请求。下面是我的代码结构:
@using (Html.BeginForm()) {
@Html.ValidationSummary(true)
<fieldset style="font-family:'B Nazanin';font-size:14pt">
<div align="center">
<table border="0">
<tr align="center">
<td>
@Html.LabelFor(model => model.a)
</td>
<td>
@Html.LabelFor(model => model.a)
@Html.EditorFor(model => model.a)
@Html.ValidationMessageFor(model => model.a)
</td>
</tr>
</table>
<div align="right" id="searchJustForm">
<fieldset style="font-family:'B Nazanin';font-size:14pt">
@using (Ajax.BeginForm("Index", "Terminal", new AjaxOptions() { UpdateTargetId = "divGomrokJust", InsertionMode = InsertionMode.Replace }))
{
<div align="center">感谢您的关注。
发布于 2011-07-03 22:46:03
不能嵌套HTML表单。这是无效的HTML。您将不得不修改您的标记。您可以通过订阅表单元素的.change事件来使用纯jQuery,并使用$.ajax方法触发AJAX请求。
发布于 2011-07-05 04:39:18
使用jQuery库(www.jquery.com)中的$.post Javascript函数将是最佳解决方案
https://stackoverflow.com/questions/6563543
复制相似问题