jQuery の AJAX メソッドでコメントを追加すると首が絞められます。ストレスが溜まった後、このテキストボックスを null にしたいです。
このような私のAjaxメソッド:
function AddComments() {
$(".Comment input[type=text]").keypress(function (e) {
if (e.which == 13) {
var comment = $("#" + this.id).val();
var textId = "#" + this.id.replace("txt", "div");
$(textId).append(comment);
$.ajax({
type: "POST",
url: "Posts.aspx/AddComments",
data: "{'id': '" + this.id.replace("txt", "") + "','comments': '" + comment + "'}",
dataType: "json",
contentType: "application/json",
success: function (response) {
$("#" + this.id).val("");
//alert(response.d);
}
});
}
});
}
私が欲しいのは成功であり、現在のテキストボックスをNULLにしたい
$("#" + this.id).val("");