php - My autocomplete results are appearing with html tags -


when start writing on input, results appear html tags, example, if search "t" get: title<p><span>content</span></p>. , want title content, without no html tags.

this php:

$search = isset($_get['term']) ? $_get['term'] : ""; $pdo = conecting(); $read = $pdo->prepare("select * articles title ?");    $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 jquery 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 know how solve this?

try using way:

add code after autocomplete initialization:

.data("ui-autocomplete")._renderitem = function (ul, item) {      return $("<li></li>")          .data("item.autocomplete", item)          .append("<a>" + item + "</a>")          .appendto(ul);  }; 

like this:

$('.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());     } }).data("ui-autocomplete")._renderitem = function (ul, item) {      return $("<li></li>")          .data("item.autocomplete", item)          .append("<a>" + item + "</a>")          .appendto(ul);  }; 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -