I have ajax function on aspx page.
 function fav() {
            var p = "3";
            var e = document.getElementById('<%= ddlCountry.ClientID %>');  
            var j = e.options[e.selectedIndex].text;
                //var aralik = p[1] + p[2];
                $.ajax({
                    type: "POST",
                    url: "STry.aspx/Fill",
                    data: "{'Param': '" + p + "','Param2': '" + j + "'}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    error: function (xhr, status, error) {
                        //alert the error if needed              
                    },
                    success: function (msg) {
                        var data = msg.d;
                        if (data.indexOf(',') < 0)
                        {
                            document.getElementById('<%= ddlCity.ClientID %>').options.add(data);
                        }
                        else
                        {
                            data.split(",").forEach(function (item) {
                                var opt = document.createElement(item);
                                document.getElementById('<%= ddlCity.ClientID %>').options.add(opt);
                            });
                        }
                    }
                });
        }
the data return var data = msg.d; so, my return data is data. data type like this, if one more than;
text1,text2,text3,text4
and i want to split this value and add dropdownlist that is ddlCity
this part is my try:
var data = msg.d;
      if (data.indexOf(',') < 0)
        {
          document.getElementById('<%= ddlCity.ClientID %>').options.add(data);
        }
         else
         {
            data.split(",").forEach(function (item) {
            var opt = document.createElement(item);
            document.getElementById('<%= ddlCity.ClientID %>').options.add(opt);
         });
but it is not working.
Briefly, I have a return data  like  (text1,text2,text3,text4)  how to add return data in ddlCity item on javascript?
Thank you for your answers.
 
     
     
    