Werk de code bij zoals hieronder en probeer:
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top" name="paypalform" id="paypalform">
<input type="hidden" name="cmd" value="_s-xclick">
<input type="hidden" name="hosted_button_id" value="XXXXXXXXXXXX">
<button type="submit" class="radius paypal-button prevented" name="submit" id="paypalsubmit" alt="PayPal - The safer, easier way to pay online!">Buy Now!
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
En het script gaat als volgt:
<script>
$(document).ready(function(){
$('#paypalsubmit').click(function(e) {
if($(this).hasClass('prevented')){
e.preventDefault();
$(this).removeClass('prevented');
$.post( "ajax.create_sponsorship.php",{ data: 'XXXXXX'}, function( result ) {
if(result){
$('#paypalsubmit').click();
return true;
}
});
}else{
$('#paypalform').submit();
$(this).addClass('prevented');
}
});
})
</script>
Ik hoop dat dit helpt.