A
A
Andrey2017-08-22 16:38:15
PHP
Andrey, 2017-08-22 16:38:15

Ajax fires 3 times?

Good afternoon!
There is a script for js and jquery, or rather an ajax request, but it works something like 3 times:

$(document).ready(function(){	
$('.my_basket_call').on('click', function(){
    var kolp = $(this).attr("data-offer-id");	
    var buy_id = $(this).attr('id');
     var inputId = $(this).data('input');
    var newValue = $('#'+inputId).val(); //прибавили +1
    console.log(kolp);
    console.log(buy_id);
    console.log(newValue);
    $.ajax({
      url: 'request.php',
      type: 'POST',
      data: ({basket:buy_id, quinity: newValue,torg_p:kolp}),
      dataType: 'html',
      beforeSend: funcBuy,
      success: funcSuccessbuy
    });
  });
  
    function funcBuy() {
    
    }
    function funcSuccessbuy(data) {
      $('.show_basket').html(data);
    }	
});

I can't understand why
(site on the 1c bitrix engine)
Maybe someone knows what could be the problem?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrey, 2017-08-23
@Andrey_Tech

I solved the problem in my own way, suitable for those who work on 1c bitrix:
just where the repetition occurs, add this code after ajax:
jsAjaxUtil.CloseLocalWaitWindow();

A
Alexey Emelyanov, 2017-08-22
@babarun

Is this code in a component? Maybe the component is connected three times on the page.

V
Vadim Dunkin, 2017-08-22
@vadimushka_d

check what events are hung on this element, it can be stupid three times the click event is hung on the element

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question