In my ajax form i have some checkboxes and a textbox for email address. The form work, but i can’t send the checkboxes array and email address in the same variable. Sorry for my bad english. Here’s jquery code :
$(document).ready(function () {
$('#submit').click(function () {
var valore = { 'how_hear[]' : []};
$("input:checkbox:checked").each(function() {
valore['how_hear[]'].push($(this).val());
}); // Checkboxes value
var name = $('input:text');
// Organization of data to send to php. I think the problem is here, but i can’t solve!!!
var data = 'name=' + name.val() + '&check=' valori;
$.ajax({
type:'POST',
url:'myurl.php',
data: data, // If i send only the variable "name" or only the variable "valore", it works fine!
cache: false,
success:function (data) {
$('form').append('GIUSTO!!!!');
}
});
return false;
});
});
Any suggestion? Thank u!
You can use
serializeArray()orserialize()method.