I have the following HTML:
<input type='text' name='af_student_startdate' id='start115'>
<input type='text' name='af_student_startdate' id='start116'>
And the following jQuery
$('#save').click(function() {
var values = {};
$('input[name="af_student_startdate"]').each(function(n, el){
values [ $(el).attr('id') ] = $(el).val();
});
$.ajax( {
type : 'POST',
url : '/update.php',
data : {af_student_startdate: values}
});
})
This will POST for example:
af_student_startdate[start115] 2012-09-01
af_student_startdate[start116] 2012-09-25
How can I remove the text “start” so that I only POST the INT values to update.php?
Try this:
You can also code:
Which is faster and better than creating unnecessary jQuery objects.