I want to clear textbox after ajax posting.
<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>
there are a lot of example, but they do not work. I m already using this code, but it is too slow.
$("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("");
});
});
Is there any way to do this.
I usually use the Ajax function. But anyways I believe the key to your problem is that you have no success function. Try something like this.