我有一个下拉列表。我正在尝试在不使用按钮的情况下在单击事件上保存该下拉列表的数据。我尝试了一些代码,但它不起作用,请帮忙。这是我的下拉列表的视图
@model MyYello.Admin.Models.FeedBack
@{
ViewBag.Title = "Feed Back";
}
@*@using (Ajax.BeginForm("SelectFeedBack", "Admin", new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "mainContent" }, new { @id = "formId" }))
*@
<form method="post" id="formId" action="@Url.Action("SelectFeedBack","Admin")">
@Html.ValidationSummary(true);
<fieldset>
@Html.HiddenFor(item => item.FeedBackId)
<legend>Create Notes</legend>
<div class="editor-label">
@Html.LabelFor(item => item.FeedBackDrpDown, "Select feed Back")
</div>
@Html.DropDownList("FeedBack")
<input type="hidden" id="isNewNote" name="isNewNote" value="false" />
@* <p>
<input type="Submit" value="Save" id="Save" />
</p>*@
@* @Url.Action("CreateNote", "Admin")*@
</fieldset>
</form>
<script type="text/javascript">
$(function () {
$("#FeedBack").change(function () {
console.log("test");
$("#formId").submit(function () {
console.log("test1");
$.ajax({
type: "POST",
//url: urlAction,
data: {},
datatype: "JSON",
contentType: "application/json; charset=utf-8",
success: function (returndata) {
if (returndata.ok)
window.location = returndata.newurl;
else
window.alert(returndata.message);
}
});
});
});
});