I have a php array:
$array = array(‘1234’=>”Acme Company”,
“4321”=>”CustomerX”,
”1056=>”CustomerY”,
”1058”=>”google”,
”1059”=>”Yahoo”,
”1060”=>”apple”);
I am attempting to create an autocomplete with this data. so step 1 is to iterate through in javascript.
var clients = '<?php echo json_encode($array);?>';
$.each(clients, function(i,el){
alert(i+","+el);
});
When i do this, I get the error:
Uncaught TypeError: Cannot use 'in' operator to search for '2847' in {“1234”:”Acme Company”,”4321”:”CustomerX,”1056”:”CustomerY”,”1058”:”google”,”1059”:”Yahoo”,”1060”:”Apple}
I can not figure out why. if i alert(clients)
, it looks like a good array..