How can I send many types of data with AJAX?
I don't know how to write data
in this function for this state:
$('#edit_product').live('click', function () {
var category = $('#category').val();
var pro_name = "My name";
var id = [];
$(".value").each(function() {
value.push($(this).val());
});
$.ajax({
type: 'POST',
url: '/add.product.php',
data: , // What do I have to put here???
success: function (data) {
$('#result').html(data);
}
});
});
Adding something similar you will get post request with fields "category", "pro_name" and "id"
$.ajax({
type: 'POST',
url: '/add.product.php',
data: {
category: category,
pro_name: pro_name,
id: id
},
success: function (data) {
$('#result').html(data);
}
});