Problem with XML and Jquery UI Autocomplete
Hi guys.
I was hoping somebody would be able to help me. Basically I am trying to use the Jquery autocomplete with an XML datasource and cannot seem to get it working.
A sample of the XML is as follows:
--------------------------------------…
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE sitelisting SYSTEM "schema/sitelisting.dtd"><sites>
<site>
<id>8</id>
<site_name>Site 1</site_name>
</site>
<site>
<id>7</id>
<site_name>Site 2</site_name>
</site>
<site>
<id>6</id>
<site_name>Site 3</site_name>
</site>
<sites>
--------------------------------------…
This is the code from my Jquery Autocomplete page:
--------------------------------------…
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Jquery Site Search</title>
<link rel="stylesheet" href="css/jquery-ui-1.8.9.custom.css">
<script src="js/jquery.min.1.4.4.js"></script>
<script src="js/jquery.ui.core.js"></script>
<script src="js/jquery.ui.widget.js"></script>
<script src="js/jquery.ui.position.js"></script>
<script src="js/jquery.ui.autocomplete.js"></scr…
<link rel="stylesheet" href="css/dropdown.css">
<script>
$(function() {
$.ajax({
url: "http://159.63.60.147/sitelistxml",
dataType: "xml",
success: function( xmlResponse ) {
var data = $( "site", xmlResponse ).map(function() {
return {
value: $( "name", this ).text() };
}).get();
$( "#tags" ).autocomplete({
source: data,
minLength: 0,
});
}
});
});
</script>
</head>
<body>
<div class="demo">
<h1>Jquery Site Search</h1>
<div class="ui-widget">
<label for="tags">Tags: </label>
<input id="tags" size="40" />
</div>
</div><!-- End demo -->
</body>
</html>
--------------------------------------…
Any ideas what is wrong. I am guessing something is wrong with my Javascript. But I cannot work out exactly what!
Thanks