I need help populating my dropdown with my JSON response

后端 未结 1 469
太阳男子
太阳男子 2020-12-21 17:42

I\'m getting JSON back in this format from my C# webmethod:

{\"d\":[\"ADAMS CITY\",\"BOULDER\",\"ANTON\",\"ARBOLES\"]}

I now have a asp.net

1条回答
  •  隐瞒了意图╮
    2020-12-21 18:09

    Here's something that should do fine inside of your success callback:

    var $select = $("#parkcity");
    
    $.each(data.d, function(i, el) {
        console.log(el);
        $select.append($("

    Example: http://jsfiddle.net/z2D8f/

    Or an alternative that appends the HTML all at once, which is probably faster:

    var html = $.map(data.d, function(el) {
        return "";
    });
    
    $("#parkcity").append(html.join(''));
    

    Example: http://jsfiddle.net/pUhw2/

    0 讨论(0)
提交回复
热议问题