I am trying to send to php the result of an ajax form, however which button was pressed (submit or cancel) is important to the php code, but is lost during the ajax. I am trying to uncover which button was pressed to submit the form, but my code is not working.
Can someone point out what is going wrong here?
$('.form').live('submit', function(event) {
var messageTo = $(this).next();
var button = event.target;
var data = $(this).serialize();
data = data + "&" + button.name + "=" + button.value;
$.post(
'a.php',
data,
function(data){
messageTo.html(data.message);
}, "json"
);
return false;
});