未捕获的TypeError:尝试通过JQuery发送值时,$(...).value不是函数 [英] Uncaught TypeError: $(...).value is not a function when trying to send a value via JQuery

查看:99
本文介绍了未捕获的TypeError:尝试通过JQuery发送值时,$(...).value不是函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<!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>

我看到了

未捕获的TypeError:$(...).value不是函数"

"Uncaught TypeError: $(...).value is not a function"

无论何时提交数据,我都不知道为什么.我正在尝试通过POST将文本字段中的数据发送到send.php.

whenever I submit data, and I'm not sure why. I'm trying to send the data in the text field via POST to send.php.

任何帮助将不胜感激,谢谢!

Any help would be appreciated, thanks!

推荐答案

jquery中没有名为value的函数.

There is no function named value in jquery.

{ chat_message: $('#m').value() }

应该是-

$('#m').val()

这篇关于未捕获的TypeError:尝试通过JQuery发送值时,$(...).value不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆