ok

Mini Shell

Direktori : /home2/selectio/public_html/tnpsctestbatch.com/admin/modal/
Upload File :
Current File : /home2/selectio/public_html/tnpsctestbatch.com/admin/modal/category-update.php

<?php
include "../config/config.php";
$ids = $_GET['id'];
    $statement = $pdo->prepare("SELECT * FROM tbl_category e where e.id=".$ids);
    $statement->execute();
    $datas = $statement->fetchAll(PDO::FETCH_ASSOC);
    $totalData = $statement->rowCount();

if($totalData==1){
    
?>   
<style>
.modal-open .modal {
    overflow-x: hidden;
    overflow-y: hidden;
}
</style>

<div class="modal-dialog modal-lg" role="document" id="update_modal" style="overflow-x: hidden; overflow-y: hidden;">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title mt-0" id="myLargeModalLabel">Update Category</h4>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close" style="margin-top: -25px;"><i class="fa fa-times"></i></button>
            </div>
            
            <form id="update_form" method="post">
                
                <input type="hidden" name="ids" value="<?=$datas[0]['id']?>" >
                
                
            <div id="content-div">
            
            
            <div class="modal-body" style="padding: 20px 40px 20px 40px;">
                
                    <div class="form-group">
                        <label>Category</label>
                        <input type="text" name="category_name" id="category_name" class="form-control" value="<?=$datas[0]['name']?>" required>
                    </div>
                    
                    <div class="form-group">
                        <label>Status</label>
                        <select name="status" class="form-control" id="status" style="width: 100%;" required>
                            <option value="1" <?php if($datas[0]['status']==1){echo "selected";}?>>Active </option>
                            <option value="0" <?php if($datas[0]['status']==0){echo "selected";}?>>In-Active </option>
                        </select>
                    </div>

            </div>
            
            <div class="modal-footer">
                <button type="submit" class="btn btn-primary">Update</button>
            </div>
            
            
            </div>
            </form>
            
            
            
            <div id="loading-div" style="display: none; padding-bottom: 80px;">
                    <center> <img src="img/loading.gif" style="width: 250px;"><br><b class="blinking">Updating Please Wait...</b></center>
            </div>
            
            
            
        </div>
    </div>
<?php } ?>

<script>
    $('#update_form').on('submit', function(e){
        console.log("Click And Form Working");
                e.preventDefault();
                $('#loading-div').show();
                $('#content-div').hide();
                var formData = new FormData(this);
                formData.append('type', 'category_edit');
                            $.ajax({
                            url: 'apis/category-api.php',
                            type: 'post',
                            dataType: 'json',
                            data: formData,
                            cache: false,
                            contentType: false,
                            processData: false,
                            enctype: 'multipart/form-data',
                            success: function (response) {
                                if(response['status']==200){
                                     alert(response['message']);
                                     $("#update_modal .close").click();
                                     $('#update_form').trigger("reset");
                                     emp_datas();
                                     $('#loading-div').hide();
                                     $('#content-div').show();
                                }else{
                                    alert(response['message']);
                                    $('#loading-div').hide();
                                    $('#content-div').show();
                                }
                            }
                        });
                
    });
</script>

Zerion Mini Shell 1.0