Please Guide Php Code for Ajax Connection

50 views Asked by At

AOA, I'm taking course "Create POS System - Inventory & sales with PHP 7 & adminLTE" But i'm creating as CMS "Cost Management System" by taking lectures i done user management & add my users but now i'm stuck in edit lecture, i'm doing exactly same what he is doing in video, Please Someone help me now as I'm sharing you my code,

File is Users.js

Users.js

/*=============================================
EDITING USER
=============================================*/
$(document).on("click", ".btnEditUser", function(){

    var idUser = $(this).attr("idUser");
    console.log("idUser", idUser);

    var dataForm = new FormData();
    dataForm.append("idUser", idUser);

    $.ajax({

        url: "ajax/users.ajax.php",
        method: "POST",
        data: dataForm,
        cache: false,
        contentType: false,
        processData: false,
        dataType: 'json',

        success: function(answer){
            
            console.log("answer", answer);

        }

    });

 });

Next File is users.ajax.php

Users.ajax.php

     <?php

 require_once "../Controllers/User.Controller.php";
 require_once "../Modules/User.Modules.php";
class AjaxUsers{

    /*=============================================
    EDIT USER
    =============================================*/

    public $idUser;

    public function ajaxEditUser(){

        $item= "id";
        $value = $this->idUser;

        $answer = UserController::ctrShowUsers($item, $value);

        echo json_encode($answer);
    }


    

/*=============================================
EDIT USER
=============================================*/

if (isset($_POST["idUser"])) {

    $edit = new AjaxUsers();
    $edit -> idUser = $_POST["idUser"];
    $edit -> ajaxEditUser();
}

Please Guide console.log("answer", answer); isn't display anything in my chrome.. after cleaning cache too

console.log("answer", answer); isn't display anything in my chrome..

0

There are 0 answers