<!DOCTYPE html>
<html>
<head lang="en">
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
<meta charset="UTF-8">
<title>PHP socket chat</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font: 13px Helvetica, Arial; }
form { background: #000; padding: 3px; position: fixed; bottom: 0; width: 100%; }
form input { border: 0; padding: 10px; width: 100%; margin-right: .5%; }
form button { width: 9%; background: rgb(130, 224, 255); border: none; padding: 10px; }
#messages { list-style-type: none; margin: 0; padding: 0; }
#messages li { padding: 5px 10px; }
#messages li:nth-child(odd) { background: #eee; }
</style>
</head>
<body>
<ul id="messages"></ul>
<form action="">
<input type ="text" id="m" autocomplete="off" />
<input type="submit" value="Submit" onclick="$('#messages').load('send.php', { chat_message: $('#m').value() });" />
</form>
我看到一个
“未捕获的类型错误:$(…).value 不是函数”
每当我提交数据时,我都不确定为什么。我正在尝试通过 POST 将文本字段中的数据发送到 send.php。
任何帮助将不胜感激,谢谢!
原文由 Vladimir Marenus 发布,翻译遵循 CC BY-SA 4.0 许可协议
jquery 中没有名为
value
的函数。它应该是 -