ajax - getJSON() 方法

    $("body").on("click",".layui-input-inline:eq(3)",function(){
        $(this).find("dd").click(function(){            
            var examId = $(this).attr("lay-value");
            if("0"!=examId){
                var herf = "/exam_papers?exam_id="+examId;
                $.getJSON(herf, function(json) {
                    var n = json.length;
                    var html = "";for(var i=0;i<n;i++){var html = "<option value='"+ json[i].id +"'>"+json[i].title+"</option>";
                        $("#examPaperSelect").append(html);
                    }
                });
            }
        });
    });

http://www.w3school.com.cn/jquery/ajax_getjson.asp

posted @ 2017-06-13 10:53  boyanh  阅读(572)  评论(0编辑  收藏  举报