您好我使用了paypal的自适应支付,当我点击付费按钮时它会打开迷你浏览器,但我希望只有在收到广播时才能打开它。
<script type="text/javascript" charset="utf-8">
var returnFromPayPal = function() {
document.getElementById('loading').style.display = 'block';
document.getElementById('fade').style.display = 'block';
$.ajax({
type: "POST",
url: "<?php echo base_url().'room_booking/success_handler' ;?>",
data: {
'roomdata': roomData,
'userdata': userData
},
success: function(response) {
document.getElementById('loading').style.display = 'none';
document.getElementById('fade').style.display = 'none';
if (response == 'cancelled') {
$("#paymentError").html('<span class="disablebtnInfo" id="msg" style="display:block;margin-left: 40%;"><span class="error_sign">Oops !</span> <span id="errmsg">Your payment was interrupted, please make sure your payment</span></span></strong>');
} else {
$("#step3").removeClass("progtrckr-todo").addClass("progtrckr-done");
$("#step4").removeClass("progtrckr-todo").addClass("progtrckr-done");
$("#replaceMe").html(response);
}
}
});
// Here you would need to pass on the payKey to your server side handle to call the PaymentDetails API to make sure Payment has been successful or not
// based on the payment status- redirect to your success or cancel/failed urls
};
var dgFlowMini = new PAYPAL.apps.DGFlowMini({
trigger: 'submitBtn',
expType: 'mini',
callbackFunction: 'returnFromPayPal'
});
</script>
如何做到
答案 0 :(得分:1)
假设单选按钮是页面上的一段HTML,例如,并且您正在使用jquery,那么将$ .ajax()调用放在单选按钮的测试中,例如:
if ($('#dopaypal').val()) {
$.ajax(...)
}