What is the problem with my JQuery code when I click on the button it does not work, I searched a lot and tried many ways but my problem not solved. I used this code in other files, on there it works correctly but it not work in this file.
this my table:
<table class="table table-bordered"> <tbody> <?php $insideOrders = \App\OutsideModel::where('total_id', '=', $order->order_id)->get(); ?> @foreach($insideOrders as $index => $inside) <tr> <td></td> <td></td> <td></td> <td></td> <td> @if($order->status=='1') <button id="send_order" class="btn btn-primary btn-xs" order_id="">ارسال<i id="send_icon"></i> </button> @else <button class="btn btn-success btn-xs" disabled>ارسال شده</button> @endif </td> </tr> @endforeach </tbody> </table>
This is my js:-.
$('table tbody').on('click', 'button', function () { var order_id = $(this).attr("order_id"); $.ajax({ url: '', type: 'GET', dataType: 'json', data: { 'id': order_id }, success: function (response) { if (response) { alert('ارسال شد!'); window.location.reload(); } else { alert('ارسال نشد!') } }, error: function (err) { } }) });
https://stackoverflow.com/questions/67414100/why-jquery-code-does-not-work-when-i-click-on-button May 06, 2021 at 04:01PM
没有评论:
发表评论