> I want recive message from post.asp how do it ?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 to recive message from this post... how do it..**
//$.post("post.asp",{update2:firstname} , function(data),
$("#chatbox").append($(this).val() + "<br/>");
$(this).val("");
e.preventDefault();
}
});
});
</script>
答案 0 :(得分:1)
我建议使用ajax()
这样的事情:
$.ajax({
type: "POST",
url: "post.asp",
data: { update2: firstname } //you can add more values in here if you need
}).done(function( msg ) {
alert( "Data Saved: " + msg );
});
完成ajax()调用后将触发完成。
如果您需要检查此代码是否按照您的意愿完成,那么您可以使用以下内容:
$.ajax({
type: "POST",
url: "post.asp",
data: { update2: firstname }, //you can add more values in here if you need
cache: false,
success: function(response)
{alert(response);}
}).done(function( msg ) {
alert( "Data Saved: " + msg );
});
编辑:
如果您只想发布,那么您可以使用以下内容:
$.post("test.php", { name: "John", time: "2pm" }).done(function(data) { alert("Data loaded: " + data);});