Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught TypeError: $(...).value is not a function when trying to send a value via JQuery

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

like image 993
Vladimir Marenus Avatar asked May 06 '15 11:05

Vladimir Marenus


People also ask

Is not a function error in jQuery?

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.

How do I fix uncaught Typeerror Ajax is not a function?

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.

Is not a function Typeerror is not a 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.

Is not a function at JavaScript?

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.


1 Answers

There is no function named value in jquery.

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

It should be -

$('#m').val()
like image 71
Sougata Bose Avatar answered Oct 16 '22 17:10

Sougata Bose