I've been trying to use a remote JSON datasource but just isn't working so I'm giving an XML solution a try.
The code I have is along the lines:
- From: <input id="frmFlightFrom" name="frmFlightFrom" type="text" class="Airports" value="" />
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery.ajax({
url: "http://www.proudlycarbonneutral.com/CarbonFootprintCalculator/FlightList.aspx",
dataType: "xml",
success: function( xmlResponse ) {
var data = jQuery( "airport", xmlResponse ).map(function() {
return {
value: jQuery( "name", this ).text()
};
}).get();
jQuery( ".Airports" ).autocomplete({
source: data,
minLength: 0;
}
};
});
});
</script>
the XML is along the lines:
- <airports>
- <totalResultsCount>3</totalResultsCount>
- <airport><name>GIG - Galeao Antonio Carlos Jobim (Brazil)</name></airport>
- <airport><name>LAX - Los Angeles International (United States)</name></airport>
- <airport><name>LOS - Lagos Murtala Muhammed (Nigeria)</name></airport>
- </airports>
Is there anything obviously wrong with this?
Thanks
David