I have used below code for set selected values into select2() but it not working when i am getting values dynamic from ajax. If a added static values then it is working fine. So help me about this. Below i added my code in that first one working and second one not.
I got the values of [response['pictoGramArr']
this from ajax is "GHS02","GHS04"
var arr = ["GHS04","GHS09"];
$("#ing_pictogram").select2("val", arr);
$("#ing_pictogram").select2("val", [response['pictoGramArr']]);
There is no any error in console, so why not working?