异步刷新前后台的代码

前台代码:

 $.ajax({
                    type: "POST",
                    url: "/Admin/Project/GetArealist?id="+cityid,
                    dataType: "json",
                    timeout: 20000,

                    success: function (data) {
                        
                        if (data != null) {
                           // var txt = JSON.stringify(data);
                            var txt = data;
                            $("#City_Id").html("");
                            var tobody = "";
                            for (var i = 0; i < txt.length; i++) {

                                tobody += "<option value='" + txt[i].Id + "'>" + txt[i].Name + "</option>";
                            }
                            $("#City_Id").append(tobody);

                        };
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        alert(textStatus);
                    }
                });

后台json格式化list

  var json = JsonConvert.SerializeObject(Arealist);//Arealist为list列表

 

你可能感兴趣的:(异步刷新前后台的代码)