My $.ajax() is not serializing the button name and value.
I have a very simple form. It has a button and a textbox.
Here's a catch-all solution that will look for an input in the button's containing form. If it exists, it'll set the value, otherwise it will create a hidden input and set its value. This can also be useful if you're not wanting to submit the form immediately.
$(document).on('click', '[name][value]:button', function(evt){
var $button = $(evt.currentTarget),
$input = $button.closest('form').find('input[name="'+$button.attr('name')+'"]');
if(!$input.length){
$input = $('', {
type:'hidden',
name:$button.attr('name')
});
$input.insertAfter($button);
}
$input.val($button.val());
});