connect_error) { die("Connection failed: " . $mysqli->connect_error); } $ID = $_POST['ID']; $results = $mysqli->query("SELECT * FROM PresidentialCandidate WHERE ID='$ID'"); if( $results->num_rows > 0 ) { $row = mysqli_fetch_array($results,MYSQLI_ASSOC); //Instead of just echoing out the ID, you need to build the result/data that you want in the div right here. The success function of the AJAX call will append whatever you echo out here echo $row['ID']; } ?>