jQuery автозаполнение удаленного источника амперсанд (& amp;) проблема с формой PHP

Я использую виджет автозаполнения JQuery с удаленным источником. Виджет работает нормально, кроме случаев, когда запись имеет амперсанд (&). JSON, который создается моей страницей php, правильно отображает данные с помощью одного & условное обозначение. Но виджет интерпретирует его как HTML &,

HTML & из виджета затем вызывает мою форму php, чтобы сломаться. Любая помощь будет принята с благодарностью. Я пробовал несколько вещей, и, кажется, ничего не работает.

Вот jQuery:

<script>
$(function() {
function log( message ) {
$( "<div>" ).text( message ).prependTo( "#log" );
$( "#log" ).scrollTop( 0 );
}
$( "#company" ).autocomplete({
source: "autoComp/cds.php",
minLength: 2,//search after two characters
select: function( event, ui ) {
log( ui.item ?
"Selected: " + ui.item.value + " aka " + ui.item.id :
"Nothing selected, input was " + this.value );
}
});
});
</script>

Моя исходная страница php:

 <?php

$mysql = new mysqli("localhost", "root", "root", "casting2", 3306);

// If the connection didn't work out, there will be a connect_errno property on the $mysql object.  End
// the script with a fancy message.
if ($mysql->connect_errno) {
echo "Failed to connect to MySQL: (" . $mysql->connect_error . ")";
}//connect to your database

$term = $_GET['term'];//retrieve the search term that autocomplete sends
$theQuery = "SELECT company AS value, company AS id FROM cds WHERE company LIKE '%".$term."%'";

$result = $mysql->query($theQuery);

unset($row_set);


// Move to row number $i in the result set.
for ($i = 0; $i < $result->num_rows; $i++) {
// Move to row number $i in the result set.
$result->data_seek($i);

// Get all the columns for the current row as an associative array -- we named it $aRow
$aRow = $result->fetch_assoc();

$aRow['value'] = htmlentities(stripslashes($aRow['value']));
$aRow['id'] = htmlentities(stripslashes($aRow['id']));
$row_set[] = $aRow; //build an array
}
echo json_encode($row_set);//format the array into json data

$result->free();

?>

А вот пример записи из массива:

[{"value":"Bowling & Miscia Casting","id":"Bowling & Miscia Casting"}]

Спасибо!

1

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector