Reputation: 229
This is what I have tried so far; and these are the values it is returning:
$('input[name=message]').toString()
"[object Object]"
$('input[name=message]').val()
undefined
$('input[name=message]').toString()
"[object Object]"
$('input[name=message]').html()
null
Can anyone suggest how I can post the text within json?
This is the current code:
$('form input[type=image]').click(function() {
var $data = 'name=' + $('input[name=name]').val() + '&' +
'email=' + $('input[name=email]').val() + '&' +
'country=' + $('input[name=country]').val() + '&' +
'contact=' + $('input[name=contact]').val() + '&' +
'message=' + $('input[name=message]').val() + '&' +
'service=' + $('input[name=service]:selected').val() + '&' +
'csrf=' + $('input[name=csrf]').val();
$.post( 'http://www.site.com/system/sendemail.php',
$data,
function($data, $textStatus) {
if ($data.success) {
$('input[name=name]').val();
$('input[name=email]').val();
$('input[name=country]').val();
$('input[name=contact]').val();
$('input[name=message]').val();
$('input[name=service]').attr('selected', '');
$('input[name=csrf]').val($data.newCSRF);
}
$.prompt($data.result);
},
'json');
return false;
});
Upvotes: 0
Views: 91
Reputation: 2164
If it is textarea , use textarea
instead of input
.
Instead of:
$('input[name=message]').val()
try this:
$('textarea[name=message]').val()
Upvotes: 3
Reputation: 1891
You may use wrong selector, I think you must change input into textarea:
$('textarea[name=message]')
Upvotes: 2