<!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>
I am seeing an
"Uncaught TypeError: $(...).value is not a function"
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!
on if not a function" jQuery error occurs for 2 main reasons: Loading an old version of the jQuery library that doesn't support the on function. Loading a library that overrides the value of the dollar sign $ variable.
To solve the "$. ajax is not a function" error, add the regular jQuery script to the page and remove the slim version. The slim jQuery version does not include the ajax function.
This is a standard JavaScript error when trying to call a function before it is defined. This error occurs if you try to execute a function that is not initialized or is not initialized correctly. This means that the expression did not return a function object.
The JavaScript exception "is not a function" occurs when there was an attempt to call a value from a function, but the value is not actually a function.
There is no function named value
in jquery.
{ chat_message: $('#m').value() }
It should be -
$('#m').val()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With