I have used wp_localize_script()
to pass a variable to a javascript file.
var countries = [searchresults.data];
The variable is getting passed but I want it in a js file like below:
var countries = [item1,item2,item3];
The variable is correct searchresults.data = item1,item2,item3
, but the countries variable has to be like var countries = [item1,item2,item3];
iIam not able to do. Please help
This is the $data that I passed
$data = array(
'data' => $searchresult,
);
wp_localize_script( 'searchautocompleter', 'searchresults', $data );