"<td><a href=\"javaScript:toQueryChoose("+obj.id+","+qname+")\">查看选项</a></td>"+
多个参数的传递,注意下面标红的单引号,绿色为ajax动态取出来的数据
如何是数字可以直接传递,但是如果参数中包含字符串的参数需要加单引号
"<td><a href=\"javaScript:toQueryChoose("+obj.id+", ' "+obj.qname+" ' )\">查看选项</a></td>"+
"<td><a href=\"javaScript:toDel("+obj.id+")\">删除</a>  "+
//查看选项
function toQueryChoose(id,qnams) {
$("#myModal").modal('show');
$("#myModalLabel").text(qnams);
$.ajax({
type:"post",
url:"<%=path%>/question/toQueryChoose.do",
data:{"qid":id},
dataType:"json",
success:function(res){
//[{"id":842,"opcontent":"A、 水果是","qid":0},
//{"id":843,"opcontent":"B、苹果是","qid":0},
//{"id":844,"opcontent":"C、水蜜桃是","qid":0},{"id":845,"opcontent":"D、香蕉是","qid":0}]
var html="";
for(var i in res){
var obj=res[i];
html+="<li class=\"list-group-item\">"+obj.opcontent+"</li>";
}
$("[class='modal-body'] ul").html(html);
}
})
}