jQuery ajax sending multiple request on 1 click -


i don't know happened code clicking on send button send email , sending multiple duplicate emails.. same jquery , html code used in page delete files , working fine.. doing thing? wrong ? enter image description here

jquery:

$(document).on('click','.sendwork',function(e){     $('#spinner').show();     var sendwork = $(this).data('id');      var res         = sendwork.split("-");     var comment_id  =  res[0];     var status      =  res[1];     var order_id    =  res[2];     var td = $(this).closest("td").andself();      $.ajax({         type:'post',         url:'{!! url::to('admin/sendwork/') !!}',         cache: false,         data:{          '_token'   : '{{ csrf_token() }}',          'comment_id':comment_id,          'status':status,          order_id:order_id,         },         success: function(data){             $('#spinner').hide();             if (data == 'true') {                 // $('.email-resp').html('');                 td.html('email sent');             }          },         error:function(data){             $('#spinner').hide();             td.html('<p style="color:red; font-weight:bold;">fail</p>');         }     });   }); 

html:

<table class="table table-compact table-bordered">      <tr>         <th width="10"></th>         <th width="30">date</th>         <th width="20">user</th>         <th width="20">status</th>         <th width="450">comment</th>         <th width="100">files</th>     <th width="30">action</th>     </tr>      <tr>         <td><a class="del-comment" href="javascript:void(0)" data-token="xyjbzesvbftnurm0onrp75k049re0dpplynrque6" id="217"><span style="color:red;" class="glyphicon glyphicon-remove"></span></a> </td>         <td>01-apr-15</td>         <td width="30">hy</td>         <td>completed</td>         <td width="42" align="left"><p>sdf</p></td>         <td>             <a href="/uploads/pe10_1427882386_0.png" target="_blank" alt="pe10_1427882386_0.png" title="pe10_1427882386_0.png"><i class="fa fa-picture-o"></i></a>                  </td>         <td><a href="javascript:void(0)" class="btn btn-small btn-success sendwork" data-id="217-completed-leh1000">send</a></td>     </tr>  </table> 

try this

$(document).on('click','.sendwork',function(e){    // thing }); 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -