从提交表单获取变量到php而不重定向页面

first i declare an empty php variable:

<?php $ip = ' '; ?>

i have this form:

<form method="POST" action="hostnameip.php">
   <div class="form-group">
      <label for="hostname" style="color:white;">Hostname</label>
      <input type="text" style="text-align:center;" class="form-control" id="hostname">
   </div>
   <div class="row">
      <div class="col-xs-12">
         <button type="submit" value="click" name="submit" class="btn btn-primary btn-lg">Resolve</button>
      </div>
   </div>
</form>

and i have this php script:

<?php
  function hostnametoip(){
     $url = $_GET['hostname'];
     $ip = gethostbyname($url);
     return $ip;
  }
?>

what i need, is to submit my input to my php script and run function on form submit but without refreshing the page.. in theory this should run the php script with the input from form and get the ip of hostname from input saved into variable $ip, then i use jquery to refresh div displaying ip.. my jquery works, but i am failing to send variable and run php without refreshing page.. Thank You