I have got a PHP file that received data that has been posted from a form. It then sends it to a database. However I needed to get those variables and put them in JavaScript. I have done the following, but when logging the variables supposed to store the php data (in the script file) it return undefined. 
What am I doing wrong? I am new to all the languages. The files are all separate - with the PHP and Script files being external.
SCRIPT:
$(function(){
var data1 = $("#username").val();
console.log(data1);
$.ajax({
  type: "POST",
  url: 'signUp.php',
  data: ({data1}),
  success: function(data) {
    console.log("success");
  }
});
});
PHP
if (isset($_POST['signup'])){
    //The connection to the database
    include_once 'databaseHandler.php';
    //Gets the infomation submitted from the form
    //Protects the database by converting everything to text...
    //The database therefore cannot read the inputs as code
    $username = mysqli_real_escape_string($conn, $_POST['username']);
    $password = mysqli_real_escape_string($conn, $_POST['password']);
    echo (".$user.");
HTML
<form action="signUp.php" method="POST">
        <input id="usernameSignUp" type="text" name="username" placeholder="Username">
        <br>
        <input id="passwordSignUp" type="password" name="password" placeholder="Password">
        <br>
        <button class="BUTTON" type="submit" name="signup">SIGN UP</button>
    </form>
 
     
     
     
    