How use submit and ajax functions on click event? I need send input hidden to server using a link but no found in click event…. any solution? please help!
p.d. sorry for my english xd
$('#delete_link').click(function() {
$('#myform').submit(function() {
if ($('#codigo').val().length < 1) {$('#notice').html('Error'); return false; }
$.ajax({
type: "POST",
url: 'mantenimiento.php?action=Eliminar',
data: $(this).serialize(),
success: function(data) {
switch(data){
case 'success':
window.location.reload();
break;
default:
$('#notice').html('<p class="error">'+data+'<\/p>');
break;
}
}
});
return false;
});
});
this bit:
is only binding the function to the
submitevent on #myform (when#delete_linkis clicked), but doesn’t actually trigger the event.I think what you want is something like: