jquery
2013-05-14 45 views 0 likes 
0
> 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> 

回答

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({ 
     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);}); 
+1

我想进入提交功能而已,如果提交的正常功能,我可以做到这一点 – 2013-05-14 07:32:12

+0

我不知道如果我理解正确的话,尝试更具体 – 2013-05-14 07:37:57

相关问题