When I start writing on my input, my results appear with html tags, for example, if I search for "t" I get: Title<p><span>Content</span></p>
. And I want Title Content, without no html tags.
This is my php:
$search = isset($_GET['term']) ? $_GET['term'] : "";
$pdo = conecting();
$read = $pdo->prepare("SELECT * from articles WHERE title LIKE ?");
$read ->bindValue(1, "%$search%", PDO::PARAM_STR);
$read ->execute();
$data = array();
while($res = $read ->fetch(PDO::FETCH_ASSOC))
{
$data[] = $res['title'].'-'.$res['content'];
}
echo json_encode($data);
This is my jQuery to start autocomplete:
$('.j_autocomplete').autocomplete({
source: 'http://localhost/project/tpl/search.php'
select: function(event, ui){
var get= ui.item.value;
returndata(get);
},
change: function(data)
{
returndata($(this).val());
}
});
Do you know how to solve this?