jquery - textarea enter submit form how to recive post form -
> want recive message post.asp how ?thk you..
<form name="message" action=""> <textarea type="text" id="usermsg"></textarea> </form> <div id="chatbox"></div> <script type='text/javascript'> $(function() { var firstname = $("#usermsg").val(); $("#usermsg").keypress(function (e) { var firstname = $("#usermsg").val(); if(e.which == 13) { //i want recive message post... how it..** //$.post("post.asp",{update2:firstname} , function(data), $("#chatbox").append($(this).val() + "<br/>"); $(this).val(""); e.preventdefault(); } }); }); </script>
i recommend of using ajax()
something this:
$.ajax({ type: "post", url: "post.asp", data: { update2: firstname } //you can add more values in here if need }).done(function( msg ) { alert( "data saved: " + msg ); });
done triggered when ajax() call done.
if need check if code done wanted can have like:
$.ajax({ type: "post", url: "post.asp", data: { update2: firstname }, //you can add more values in here if need cache: false, success: function(response) {alert(response);} }).done(function( msg ) { alert( "data saved: " + msg ); });
edit:
if want post use like:
$.post("test.php", { name: "john", time: "2pm" }).done(function(data) { alert("data loaded: " + data);});
Comments
Post a Comment