1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| <script type="text/javascript">
function displayCredit(price, mode, selection){
var cancelled = false;
$('.link').click(function() {
cancelled = true;
});
console.log(cancelled);
$.ajax({
type: "POST",
url: decodeURI("<?= $this->basepath(); ?>/distribution/displaycredit"),
data: {
price : price,
mode : mode,
selection: selection
},
error: function(){
return false;
},
success: function(retour){
if(retour.selection != null){
if(retour.statut == 'ok' && retour.price != null && retour.mode != null){ /* Command ok */
getUrl('<?= $this->url('distribution/processing',array('selection'=>$selection,'receipt'=>$receipt)); ?>');
}
}
var old_value = $('#amout_credit_hidden').val();
if(old_value != retour.credit){
$("#amout_credit").html(retour.credit);
$("#amout_credit_hidden").val(retour.credit);
$("#amout_credit_hidden").trigger('change');
}
}
});
return cancelled;
}
function exeDisplayCredit(price, mode, selection){
var credit = displayCredit(price, mode, selection);
//console.log(credit);
if(credit == false){
setTimeout('exeDisplayCredit('+price+','+mode+','+selection+')',2000);
}
}
</script> |
Partager