why does my <br> not work ?

Posted by Vince on Stack Overflow See other posts from Stack Overflow or by Vince
Published on 2013-10-28T21:47:02Z Indexed on 2013/10/28 21:53 UTC
Read the original article Hit count: 161

Filed under:
|
|

I am returning a PHP array back to a JQuery call for appending into a div called "name-data". I want my array to be listed vertically, so I concatenate a br tag in the PHP however, when it gets to the HTML page the br is not being rendered, it just comes out as text. I have tried the various forms of br all without luck.

I am new to JQuery - What am I doing wrong ? Many Thanks !

PHP:

$result = mysqli_query($con,"SELECT FirstName FROM customer limit 5");
while($row = mysqli_fetch_array($result))
 {
echo $row['FirstName']."<br />";
}

JQuery:

$('input#name-submit').on('click',function(){
var name = $('input#name').val();
if($.trim(name) !=''){
    $.post('search.php',{name:name}, function(data){
    $('div#name-data').text(data);
    });
}
});

HTML

Name:<input type="text" id="name">
<input type="submit" id="name-submit" value="grab">
<div id="name-data"> </div>

© Stack Overflow or respective owner

Related posts about php

Related posts about jQuery