Andy,
The jQuery code that you originally posted probably orginated with me, and is useful for getting city location names from a web service called geonames.org using the JSONP protocol. Though you changed JSONP to JSON, it still has several lines in it that you do not need, and may be causing problems with your server, maybe not.
Anyway, here is some code that may be helpful as a model.
$('#state').autocomplete({
source: function(request, response) {
//Pass the selected country to the query manager to limit the selection to 1 country
$.ajax({
url: '../phpFunctions/getState.php',
data: {
term: request.term,
country: $('input[name=country]:checked').val() //Pass the selected countryAbbreviation
},
type: 'POST', // a jQuery ajax POST transmits in querystring format (key=value&key1=value1) in utf-8
dataType: 'json', //return data in json format
success: function(data) {
response($.map( data, function(item) {
return {
label: item.stateName,
value: item.name,
abbrev: item.stateAbbrev
};
}));
}
});
},
select: //function
open: //function
etc.
Get your server's response and copy/paste it into jsonlint.com to see if it is valid JSON format
Here is a tutorial with server code in several languages. Hope it it helpful.
http://www.jensbits.com/2010/03/29/jquery-ui-autocomplete-widget-with-php-and-mysql/