I’m trying to make some auto suggest stuff for an app. But i’m having some problems. I wrote this jquery code to detect when there is a change in the input:
function soletsgo(){
$('#theinput').keyup(function(){
value = $('#theinput').val();
if ( value.length > 2 ){
word = $('#theinput').val();
word.replace(/\s/g, " ");
$("#autodatathing").load("../pages/searchy.php?word="+word+"");
} else {
} }); }
And there is a PHP file (searchy.php) that processes some stuff:
<?php
$now = htmlentities($_GET['word']);
echo "<p>";
echo $now;
echo "</p>";
?>
But, when i put in a ‘space’ (known as ‘whitespace’) in the ‘input’, there is no result!
Could someone help?
You should do
escape(word)in javascript code, thenrawurldecode($_GET['word'])in php. Also if you have issues with utf8 encoding (i had in my past experience) you might consider using this function instead of rawurldecode.