trouble passing a variable via POST to a php script
In an Autocomplete source ajax section, I am not able to POST a variable into a php script to filter a query.
When I 'hard code' the variable var countryFilter= { "countryAbbrev": "US" };
it is received by the php statement $country=$_POST['countryAbbrev'];
and the php script executes with $country=US,
and the Firebug console shows data in its POST record.
OK so far, but I want the second element (in the above case US ) to change with user selections.
When I use JSON.stringify
selected.countryAbbrev=$('input[name=country]:checked').val();
var countryFilter=JSON.stringify(selected);
my alert for countryFilter gives me { "countryAbbrev": "US" } , which is valid JSON per jsonlint
and Firebug shows it in POST,
but the php variable is NULL and the script understandably does not execute.
I get the same results whether I json_decode $country=$_POST['countryAbbrev'] or don't decode it.
I have tried toString with no success and no POST info from Firebug. I can't get around the problem that " in javascript creates a string that is no longer a variable. There's probably a simple solution, but I don't see it.
What needs to be done?