I am making an ajax request where I will type name in input box to search data from db, It's working fine,
<script>
$(document).ready(function(){
$('input#name-submit').on('click', function() {
var nameVar = $('input#name').val();
if($.trim(nameVar) != ''){
$.post('records.php', {name: nameVar}, function(data){
$('div#name-data').text(data);
});
}
});
});
</script>
----php
if(isset($_POST['name'])){
$name = $_POST['name'];
echo $name;
Now the problem is when I embed the html into php and echo it, It prints the html also
echo "<div class='tblDiv'>";
echo "</div>";
result: <div class='tblDiv'> Name </div>
how to avoid that and get the result in style?