I've been trying to implement the Interface autocomplete plugin on my site.
The plugin calls a php script, the script returns xml, but I see no
autocomplete dropdown. Any help would be appreciated! below is the html,
php, and php debug txt.
HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Main Page</title>
<script src="assets/js/jquery.js" type="text/javascript"
language="javascript"></script>
<script src="assets/js/iutil.js" type="text/javascript"
language="javascript"></script>
<script src="assets/js/iautocompleter.js"
type="text/javascript"
language="javascript"></script>
<script src="assets/js/ifxslide.js"
type="text/javascript"
language="javascript"></script>
<link rel="stylesheet" rev="stylesheet"
href="assets/css/main.css"
media="all">
<script type="text/javascript">
$(document).ready(
function()
{
$('#autocompleteMe').Autocomplete(
{
source: 'library/autocomplete.php',
delay: 700,
autofill: true,
helperClass: 'autocompleter',
selectClass: 'selectAutocompleter',
minchars: 1
}
);
}
);
</script>
</head>
<body>
<form>
<input type=text size=50 name="car_name" id="autocompleteMe">
</form>
</body>
</html>
-----------------------------------
PHP:
error_reporting(E_ALL);
ini_set('display_errors', '1');
include('config.php');
include('data_accessor.php');
// DEBUGGING STUFF
$your_data = 'Print of $_REQUEST vars:\n\n';
foreach ($_REQUEST as $key => $val) {
$your_data .= $key . " -> " . $val . "\n";
}
// GET INPUT
$field = $_REQUEST['field'];
$value = $_REQUEST['value'];
// BUILD & RUN QUERY
$query="SELECT * FROM name WHERE name_name LIKE '%$value%' ORDER BY
name_name";
$results = $db->get_results($query, 'ARRAY_A');
// CONSTRUCT XML
$xml = "<?xml version=\"1.0\"?>\n<ajaxresponse>\n";
foreach ($results as $result) {
$xml .= "<item>\n\t<text><![CDATA[". $result['name_name']
."]]></text>\n\t<value><![CDATA[". $field ."]]></value>\n</item>\n";
}
$xml .= "</ajaxresponse>";
// DEBUGGING STUFF
$your_data .= "\n\nxml: \n\n" . $xml;
// Open debug file
$fp = fopen("autocomplete.txt", "w");
// Write the data to the file
fwrite($fp, $your_data);
// Close the file
fclose($fp);
// SEND XML TO BROWSER
echo $xml;
--------------------------------------------------------------------
DEBUG:
Print of $_REQUEST vars:
field -> car_name
value -> rear
xml:
<?xml version="1.0"?>
<ajaxresponse>
<item>
<text><![CDATA[Rear Ender]]></text>
<value><![CDATA[car_name]]></value>
</item>
<item>
<text><![CDATA[Rear Engine Mongoose]]></text>
<value><![CDATA[car_name]]></value>
</item>
<item>
<text><![CDATA[Rear Engine Snake]]></text>
<value><![CDATA[car_name]]></value>
</item>
</ajaxresponse>
--
View this message in context:
http://www.nabble.com/Interface-Autocomplete-question-tf2403569.html#a6701015
Sent from the JQuery mailing list archive at Nabble.com.
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/