I am getting some values via json type ajax request with Jquery. When I use alert(msg.options) it alerts ["1","3","8"]
If I use below script to select needed options, it works. It selects only options that have value 1 and 3 and 8 :
$('#input_6').val(["1","3","8"]);
But below script doesn't work even if it alerts the same:
$('#input_6').val(msg.options);
How can I fix this? Thank you...
msg.optionsseems to be a string. If it would be an array,alertwould show1,3,8. @Falcon's answer is probably right (despite typo), no clue why he deleted it. But to be certain about this you would have to show the JSON and how you handle the response.dataType: jsonfor the Ajax request. Then it seems you are building the JSON not correctly (or at least not suitable) for your situation.