日期:2014-05-16  浏览次数:20548 次

jquery的ajax调用后台服务方法实现下拉框联动时,json解析问题?
我在页面中通过ajax调用后台方法服务,实现联动!ajax方法如下:
$.ajax({
                        type: "post",
                        async: false,
                        contentType: "application/json; charset=utf-8",
                        data: "{id:'" + id + "'}",
                        url: "AllAssessResults.aspx/GetObjListByDeptId",    //后台webservice里的方法名称
                        dataType: "json",
                        success: function (data) {
                            alert(data);
                            var optionstring = "";
                            var dataObj = $.parseJSON(data);
                            //var dataObj = eval("(" + data + ")");

                            for (var i = 0; i < dataObj.length; i++) {
                                optionstring += "<option value=\"" + dataObj[i].usercode + "\" >" + dataObj[i].username + "</option>";
                            }

                            $("#selectObj").html(optionstring);

                        },
                        error: function (msg) {
                            alert("出错了!");