![enter image description here](https://i.stack.imgur.com/odqef.jpg)is this wrong because i get loadData as undefined?

```
 <head>
 <script type="text/javascript">               
  function loadData() {
    var name  = $("#surname").val();        
    $.ajax({     
      url: 'checkdata.php',                      
      type: 'POST',       
      data: { 'surname' : surname }        
    });
    alert(data);
   //return false;
 </script>
 </head>
<body onload="loadData()">
 <form name="form1" method="post" action="php/save-edit.php" >

```

i have a form where i want to extract data from a db and display it in the form fields on form load