jquery - Pass values in a textarea and radio input via $.ajax -
jquery - Pass values in a textarea and radio input via $.ajax -
i'm getting undefined error in ie8 on textarea , radio button when seek pass them via ajax. i've commented below next field i'm trying pass on send mail service php file. think need right syntax.
this jquery/ajax code...
var coverletter = $("textarea#coverletter").val(); $.ajax({ type: 'post', url: 'phpmailer/sendmyform.php', data: { name: $('#name').val(), from: $('#email').val(), role: $('#role').val(), message: $('#coverletter').val(), //textarea subject: $('#workfor').val() //radio button //cv: $('#cv').val(),//file upload }
i've found posts on textareas dont know hot work above code
here html...
<textarea id="coverletter" class="required"></textarea> <input type="radio" name="workfor" value="1" id="company1" class="required"> <input type="radio" name="workfor" value="2" id="company2" class="required">
you radio button selector wrong:
subject: $('#workfor').val()
that looking element id 'workfor', isn't in html sample.
to value of selected radio button in html sample need
$("input[name='workfor']:checked").val();
jquery ajax
Comments
Post a Comment