jquery - Empty Input After AJAX Post Submit -



jquery - Empty Input After AJAX Post Submit -

i want empty or clear input field after comment has been submitted through jquery ajax post submit. here jquery code using;

$(".textbox2").on('keypress', function (e) { if (e.keycode == 13 && !e.shiftkey) { e.preventdefault(); var message = $("#message").val(), privateid = $("#private"); if (message == '') { alert("message missing!!"); return; } if (privateid.is(':checked')) { var privateidval = privateid.val(); } $.ajax({ type: "post", datatype: "json", url: "shout.php", data: "message=" + encodeuricomponent(message) + "&private=" + encodeuricomponent(privateidval) + "&action=addcomment", success: function (data) { showcomment(); document.getelementbyid('message').value = ''; document.getelementbyid('message').focus(); document.getelementbyid('private').checked = ''; if (data.error) { alert(data.error); } } }); } }); input field:

<input type="text" class="textbox2" size="90" maxlength="200" name="message" id="message" autocomplete="off" style="width: 90%;">

the issue is, cleared in chrome not in safari , firefox browsers. reason? please help!

your code looking fine me., seek utilize updated jquery library, think you're using outdated library missing required functions.

jquery ajax google-chrome firefox safari

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -