1

我需要使用 mvc 和 razor 视图在我的列表框中添加值。我的代码如下:

剃刀视图:

function buttonchk() {

            $.ajax({

                success: function (data) { // in data i have the value 
                            // here what code i put?
                }
            });
        }

      @Html.ListBox("test", Model.value, new { @class = "test1" });
4

1 回答 1

0

你可以使用append

function buttonchk() {
        $.ajax({
            success: function (data) { // in data i have the value 
                for(var i=0; i<data.length; i++) {
                   $("#test").append("<option value=" + data.value + ">" + data.value + "</option>"
                }

            }
        });
    }

http://api.jquery.com/append/

于 2013-02-13T14:38:09.283 回答