I need to use ajaxStop function to call an ajax to render new html element, but after the ajax function finsihed it the ajax repeat itself over and over again, i just need to run this ajax once inside the ajaxStop function. jQuery code:
$(document).ajaxStop(function () {
$.ajax({
type: 'post',
url: url.build('test/payment/getmethod'),
cache: false,
showLoader: true,
method: "POST",
success: function(data) {
if(data!='') {
var htm ='';
htm += '<div class="payment-method-billing-address">';
$.each(data , function(i, method) {
htm += '<input type="radio" class="required" name="snap-method" value='+method.value+'">'+method.label+'<br>';
});
htm += '</div>';
$( htm ).insertBefore( ".checkout-agreements-block" );
}
return false;
}
})
return false;
});