$(".submitinfo").each(function() {
// Want to use ID as POST name
// And value as POST value
});
// Submit the data
$.ajax({
url: 'submit.php',
traditional: true,
data: {
'submit':'true',
'age':$('#age').val(),
'loss':$('#loss').val()
// somehow include results here
},
type: 'POST',
async: false,
success: function(data) {
alert(data);
},
error: function() {
alert('Submit Error');
}
});
I’ve never had to do this before, and can’t find any examples of it anywhere. I have a series of inputs with a class of submitinfo that I would like to be able to submit alongside other inputs via an ajax request. How can I do this? Check the code comments for details.
Thanks!
Create an object, and add the values in the
eachfunction to the object, and pass that object to$.ajaxas data :