Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Textarea in a form is not submitting via POST with jQuery AJAX

For a reason that is unknown to me, my form is not submitting the text typed into my <textarea>.

ajax code:

$.ajax({
type:'POST', 
url:'****.php', 
data:$('#blogForm').serialize(),
success: function(responseSubmit) { blah blah etc...

The inputs work just fine, and correctly post to my database.

The form is:

<form id="blogForm">
                        <input type="date" name="date" id="blogDate">
                        <input type="text" name="title" id="blogTitle">
                        <textarea name="blogContent" id="blogBody"></textarea>
                        <input type="submit" name="submit" id="blogSubmit">
                    </form>

And what I get when I inspect in firebug, the POST is: date=09%2F25%2F1986&title=Title&blogContent=

As you can see, the blogContent is empty. Why is this?

like image 272
mdance Avatar asked Jul 31 '12 21:07

mdance


2 Answers

I neglected to mention that I had a WYSIWYG editor attached to the text area, called nicEditor. Apparently there is a bug that forced jQuery to not serialize the textarea. Once the nicEditor was removed, it worked fine. Thanks for all the help.

like image 107
mdance Avatar answered Nov 11 '22 10:11

mdance


Change:

   data:$('#blogForm').serialize(),

To:

   data:$('#blogForm').find('input, select, textarea, button').serialize(), 
like image 21
hsuk Avatar answered Nov 11 '22 09:11

hsuk