//页面
<div class="formDiv " style="overflow: inherit">
<label>主办方</label>
<div class="host clearfix">
<select id="hostS" class="js-example-responsive" multiple ></select>
</div>
</div>
var data = {};
data['参数'] = 值;
...
$.ajax({
type: "post", //请求方式get,post
data: data, //需要传给后台的json数据
async:true, //true(异步)或 false(同步)
dataType:"json", //string、json、text、script、jsonp、xml、html
url: "", //方法路径
success: function (res) {
if (res.status == 0) {
//状态成功执行
//循环插入数据
$("#hostS").html("");
var html = "";
$.each(res.host,function (k,v) {
html += "<option value="+ v.hostid +">" + v.hostname
+"</option>";
});
$("#hostS").append(html);
} if (res.status == 1) {
//状态失败执行
}
}
})
网友评论