This is my following code in front End:

```
                             <div class="panel panel-primary">
                                <div class="panel-heading text-center text-uppercase">Birth Certificates For Overall (Pending, Completed)</div>
                                <div class="panel-body">
                                <div class="box-body">
                                  <table id="viewer" class="table table-bordered">
                                    <thead>
                                      <tr>
                                        <th>Sr No</th>
                                        <th>Reg Number</th>
                                        <th>From Hospital</th>
                                        <th>Actions</th>
                                      </tr>
                                    </thead>
                                    <tbody>
                                        <?php $Viewer->showAllData(); ?>
                                    </tbody>
                                    <tfoot>
                                      <tr>
                                        <th>Sr No</th>
                                        <th>Reg Number</th>
                                        <th>From Hospital</th>
                                        <th>Actions</th>
                                      </tr>
                                    </tfoot>
                                  </table>
                                </div><!-- /.box-body -->
                              </div><!-- /.box -->
                            </div>

```

This is my classes code in it of which i have called the object:

```
    public function showAllData()
                {
                    $query = "SELECT * FROM certificate_details ORDER BY created DESC";
                    $connection = $this->establish_connection();
                    $details = $connection->query($query);
                    $connection->close();

                    if($details->num_rows > 0)
                        {
                            $counter = 1;
                            while($detail = $details->fetch_assoc())
                                {
                                    $status = $detail['status'];

                                    if($status == 0)
                                        {
                                            $bg = "bg-danger";
                                            $issuestatus = "btn btn-success";
                                            $message = "Confirm Issue!";
                                        }
                                    elseif($status == 1)
                                        {
                                            $bg = "bg-success";
                                            $issuestatus = "btn btn-success disabled";
                                            $message = "Certificate Issued";
                                        }
                                    else
                                        {
                                            $bg = "bg-warning";
                                            $issuestatus = "btn btn-warning";
                                        }

                                    echo "
                                            <tr class='odd gradeX ".$bg."'>
                                                <td>".$counter."</td>
                                                <td>".$detail['registration_number']."</td>
                                                <td>".$this->getHospitalInfo($detail['user_id'])."</td>
                                                <td style='margin: 0;'><div class='btn btn-primary' href='#' value='".$detail['id']."' id='view-details'>View Details</div><div style='margin-left: 10px;' class='".$issuestatus."' href='#' value='".$detail['id']."' id='confirm-issue'>".$message."</div></td>
                                            </tr>    
                                         ";
                                    $counter = $counter + 1;
                                }
                        }
                }

```

I have give a specific class to the button i.e class="confirm-issue" and in the value section it hold the unique value

This is the following JQuery Code which i am triggering whenever i am calling the ("#confirm-issue").click(function(){})

```
      $("body").on("click", ".confirm-issue",function() 
        {
            var certificateId = $(this).attr('value');

            if (confirm('Are You Sure You Want To Confirm The Issue of Certificate? If Once Confirmed Can\'t be Undone.\n\t\t\t\t\tPlease Confirm That You Have Issued The Certificate.'))
                {
                    $.ajax({
                                url: 'get_data.php?id=setCertificateDetailsIssued',
                                type: 'POST',
                                dataType: 'html',
                                data: {certificate_id : certificateId},
                            })
                    .done(function(resp)
                        {
                            console.log(resp);
                            if(resp == 1)
                                {
                                    var data = "Certificate Issued Succesfully!";
                                    $(this).attr('value').val("Certificate Isssued").attr('disabled', 'true');
                                    $('#message').html("");
                                    $('#message').html(data);
                                    $('#messageModal h3.modal-title').html('');
                                    $('#messageModal h3.modal-title').html('Certificate Issued Successfully!');
                                    $('#messageModal').modal('show');
                                }

                            else if(resp == 0)
                                {
                                    var data = "There Was a Technical Error While Setting The Certificate Status To Issued. Please Try After Some Time Or Try Reloading The Page Once Again!";
                                    $('#message').html("");
                                    $('#message').html(data);
                                    $('#messageModal h3.modal-title').html('');
                                    $('#messageModal h3.modal-title').html('Technical Issue!');
                                    $('#viewer tr.gradeX').removeClass('bg-danger');
                                    $('#messageModal').modal('show');
                                }
                        })
                    .fail(function()
                        {
                            console.log("error");
                        });
                }
            else
                {
                    var data = "Please Confirm That You Have Issued The Certificate & Then Click Confirm Issue Again!";
                    $('#message').html("");
                    $('#message').html(data);
                    $('#messageModal h3.modal-title').html('');
                    $('#messageModal h3.modal-title').html('Confirmation Prompt');
                    $('#messageModal').modal('show');
                }
        });

```

The problem arises when I click on issue certificate button. The value is going to the database, is being altered, and the resp code is 1, but when the control is going to the function where if condition is met as shown in the provided js code, it isn't executing the particular JQuery code to disable the button.

[![enter image description here](https://i.stack.imgur.com/rCeRY.png)](https://i.stack.imgur.com/rCeRY.png)