将Ajax数据POST到公共PHP函数

NOTE - This is a edited snippet. This is testing at the moment and will be improved after.

I'm aiming to learn oop PHP now I got a good understanding of procedural. I'm stuck on sending this Ajax request to my php file.

Html File

<script>
 $("#Question").click(function() {

  flag = 1;

  uid = "<?php echo $uid ?>";

     var dataQuestion = {

     uid,
     flag,
     ImageOne: $("#Image1").val()

     };
       //Post with AJAX
       $.ajax({
           type: "POST",
           url: "../View/class.user.php",
           data: dataQuestion,
           perform: "QuestionsFunctions",
           success: function(Returned){ 
               $(".NotBoxSmall").text("Updated");
               $(".NotBox").text("Updated");
               flag = 0;
               console.log(Returned);
           },
           error: function(){ 
               $('.NotBox').text("Issue With Site");
               $('.NotBoxSmall').text("Issue With Site");
           }
     }); 
}); 

</script>

Php file

<?php

public function QAsk(){

if($_POST['flag'] == 1){

  $Image1 = $_POST['ImageOne'];
  $uid = $_POST['uid'];

  $insertsqlQ = "UPDATE UsersData 
                 SET Image1 = '$Image1'
                 WHERE uid = $uid";

  $resultquestion = mysqli_query($this->db,$insertsqlQ) or die(mysqli_connect_errno().json_encode("Data cannot inserted"));

  return $resultquestion;

  echo json_encode("Question Updated");

  }else{ 

    echo json_encode("Question NOPE");

    return false;

  }
}

?> 

The id sends and iv'e tested this not within the public function and it appears to be fine. The request send back is blank, outside of the function it's the error log. The issue is it says questions have been updated but no data has been added to the database.

jQuery must be initialized after the DOM ( document object model ). How should I initialize jQuery?

I'd suggest some tips: 1 - Make the id names lower case #name_of_element 2 - Grab a OO PHP book and try to practice just this, run tests using curl for instance and make your database rules work before going into the client (html, js, css) 3 - Grab a jQuery book and run tests with mock data just printing a array from PHP. At the beginning is easier study stuff separated. 4 - '$Image1' is a varchar rather than the variable $Image1. Remove the quotes