我想在發佈ajax後清除文本框。如何在ajax表單提交事件之前清除文本框文本?
<div style="padding: 5px; background-color: Silver;">
@using (Ajax.BeginForm("_MessagesPartial", "Chat", new AjaxOptions { UpdateTargetId = Model.room_id.ToString() }))
{
<div style="padding: 5px 15px 5px 5px;">
@Html.TextBox("textbox_message", null, new { @class = "text_yorum", id = "text_box_chat" })
@Html.Hidden("oda_id", Model.room_id)
</div>
}
</div>
<div id="@Model.room_id" style="height:400px;overflow-y:scroll;position: relative;">
@Html.Action("_MessagesPartial", "Chat", new { room_id = Model.room_id })
</div>
有很多的例子,但他們不工作。我已經使用這個代碼,但它太慢了。
$("form").submit(function() {
$.get('@Url.Action("_MessagesPartial", "Chat", new { room_id = Model.room_id }) ', {}, function (view) {
$("#@Model.room_id").html(view);
$("#text_box_chat").val("");
});
});
有沒有辦法做到這一點。
它的工作原理。非常感謝。 – 2012-03-29 15:43:25
很高興我能幫到你。你可以考慮[標記爲答案](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work),如果它幫助你解決問題,點擊旁邊的勾號問題。 – 2012-03-29 15:44:34
對不起。謝謝你的建議。我不知道 – 2012-03-29 15:53:41