I am trying to submit a form using jquery ajax.
<form id="from_cts" action="#" method="post">
<div>
<div class="">
<textarea id="post_dis_contents" name="" cols="" rows=""></textarea>
<input id="post_dis" type="button" value="Post" />
</div>
</div>
</form>
and my jq code is this:
$(function() {
$("#post_dis").click(function() {
var cts = $("#post_dis_contents").val();
if (cts) {
var p = $("#from_cts").serialize();
//var k = $('#from_cts').find('textarea').serialize();
alert(p);
} else {
alert('null');
}
});
});
it just simply contains a textarea there, and i try to alert its value, but nothing there, then I remove all the div elements , still nothing.
Could you please give me some advice, thanks in advance.
Give name to your textarea
it will work.
<textarea id="post_dis_contents" name="textarea1" cols="" rows=""></textarea>