所以我在我的控制台中得到了这个
index.php?usermsg=Testing+new+login&submitmsg=Send:69 Uncaught SyntaxError: Unexpected token ;
我不太清楚这是什么意思,因为我找不到任何不属于的东西
$("#submitmsg").click(function(){
var clientmsg = $("#usermsg").val();
$.post("server/send.php", {text: clientmsg, server: current_server, username: current_user});
$("#usermsg").attr("value", "");
return false;
});
html代码
<form name="message" action="">
<input name="usermsg" type="text" id="usermsg" size="63" />
<input name="submitmsg" type="submit" id="submitmsg" value="Send" />
</form>
答案 0 :(得分:2)
您需要阻止input -> submit
$("#submitmsg").click(function(e) {
e.preventDefault();
$("#submitmsg").click(function(e) {
e.preventDefault();
var clientmsg = $("#usermsg").val();
$.post("server/send.php", {
text: clientmsg,
server: current_server,
username: current_user
});
$("#usermsg").attr("value", "");
return false;
});