• 03-09-2022, 16:25:51
    #1
    php ile döngüde olan bir buttondan gelecek olan data-id attr sini nasıl alabiliriz ilkini alıyor sadece?
  • 03-09-2022, 16:32:38
    #2
    $(".order-status-modal").each(function(e) {
    var $data_id = $(this).data("content");
    $("#form-status-" + $data_id).validate({
    lang: "tr",
    rules: {},
    submitHandler: function (form, e) {
    e.preventDefault();
    $.ajax({
    url: "<?= $this->adminURL . '/orders/updateOrderStatus' ?>",
    type: "POST",
    data: new FormData(form),
    contentType: false,
    cache: false,
    processData: false,
    beforeSend: function() {
    Notiflix.Loading.Hourglass('Yükleniyor.. Lütfen bekleyiniz..');
    },
    success: function (data) {
    var data = JSON.parse(data);
    if (data.status == "error"){
    setTimeout(function () {
    Notiflix.Loading.Remove();
    Notiflix.Notify.Failure(data.message);
    setTimeout(function () {
    location.reload();
    }, 1500)
    }, 1000);
    } else {
    $("#form-status-" + $data_id)[0].reset();
    $('#order-status-modal-'  + $data_id).modal('hide');
    setTimeout(function () {
    Notiflix.Loading.Remove();
    Notiflix.Notify.Success(data.message);
    setTimeout(function () {
    location.reload();
    }, 1500)
    }, 1000);
    }
    },
    error: (error) => {
    console.log(JSON.stringify(error));
    }
    });
    
    }
    });
    });
    Örnek bir kod attım, kendine göre revize edebilirsin.
  • 03-09-2022, 16:52:23
    #3
    var elem = document.getElementById('the-span');
    var dataId = elem.getAttribute('data-id');
  • 03-09-2022, 16:57:20
    #4
    cevaplar için teşekkürler çözümü başka bi şekilde buldum aslında sorun yokmuş gelen datalar aynı olduğu için olmuş