jQuery: serializing array returns empty string

Posted by John Smith on Stack Overflow See other posts from Stack Overflow or by John Smith
Published on 2014-06-10T03:19:53Z Indexed on 2014/06/10 3:24 UTC
Read the original article Hit count: 131

Filed under:
|
|
|

I did not forget to add name attributes as is a common problem and yet my serialized form is returning an empty string. What am I doing wrong?

HTML/javascript:

<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script>
$( document ).ready( function() {
    $('#word_form').submit(function(e) {
        e.preventDefault();
        console.log($(this).serialize()); //returns an empty string
    });
});
</script>
</head>

<body>
    <div id="wrapper">
        <form name="word_form" id="word_form" method="POST">
            <input type="image" name="thumbsUp" id="thumb1" value="1" src="http://upload.wikimedia.org/wikipedia/commons/8/87/Symbol_thumbs_up.svg" style="width:50px;height:50px;">
            <input type="image" name="thumbsDown" id="thumb2" value="2" src="http://upload.wikimedia.org/wikipedia/commons/8/84/Symbol_thumbs_down.svg" style="width:50px;height:50px;">
        </form>
    </div>
</body>

Thanks!

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery