jquery 获取json 循环表格

$("#selectModel").bind("click",function(){
$("#dt tbody").html("");
$.ajax({
type: "POST",
dataType: "json",
url: ‘ComponentH.ashx‘, //提交到一般处理程序请求数据
data: "act=ModelInfo&opt=select",
success: function(data) {
var html="<tr class=‘gradeX odd‘>";
var i=0;
$.each(data,function(k,v){
for(;i<=k;i++){
if(i==0||i%3!=0){
html+="<td><input class=‘checkboxes‘ name=‘ck2‘ value=‘"+v.ModelName+"‘ type=‘checkbox‘/>"+v.ModelName+"</td>";
}
else{
html+="</tr><tr class=‘gradeX odd‘><td><input class=‘checkboxes‘ name=‘ck2‘ value=‘"+v.ModelName+"‘ type=‘checkbox‘/>"+v.ModelName+"</td>";
}
}
});
if(data.length%3==2)
{
html+="<td>&nbsp;</td></tr>";
}
if(data.length%3==1)
{
html+="<td>&nbsp;</td><td>&nbsp;</td></tr>";
}
$("#dt tbody").append(html);
}
});
$("#m3").modal("show");
});

时间: 2024-08-03 13:21:51

jquery 获取json 循环表格的相关文章

jQuery获取json数据实现代码

jQuery获取json数据实现代码:使用jQuery操作json数据是非常的频繁的,下面提供两端代码供大家参考之用,大家可以自行分析,以便灵活应用. /栏目 //发送ajax请求 $.getJSON( "../../../Templet/GetInfoHandler.ashx", //产生JSON数据的服务端页面 {id: "0", sid: "1;2;3", rid: Math.round(Math.random() * 10) }, //向

JQuery根据Json创建表格

$(function () { var getjson = { "百度": "http://www.baidu.com", "新浪": "http://www.sina.com.cn", "腾讯": "http://www.qq.com" }; $('#btn').click(function () { var tbobj = $('<table border="1&qu

jQuery获取JSON格式数据方法

getJSON方法: jQuery.getJSON(url,data,success(data,status,xhr)) $("button").click(function(){ $.getJSON("demo_ajax_json.js",function(result_data){ $.each(result_data, function(index, name_value){ $("div").append(name_value + &qu

javascript;Jquery;获取JSON对象,无刷新分页实例。

js: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>&

jquery获取json数据

 需要下载jquery的js文件 html 文件的内容  cat 1.html  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  <html xmlns="http://www.w3.org/1999/xhtml">  <

javascript;Jquery;获取JSON对象,无刷新评论实例。

  <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> <script type="text/javascri

jquery用ajax方式从后台获取json数据后如何将内容填充到下拉列表

对于问题从后台获取json数据,将内容填充到下拉列表,代码非常简单,具体过程请看下面代码. 需求:url:链接     par:ID       sel:下拉列表选择器 function BuildSelectBox(url, par, sel) {  $(sel).empty();  $.getJSON(url, { id: par }, function (json, textStatus) {   for (var i = json.length - 1; i >= 0; i--) {  

JQuery UI获取JSON数据

最近在学习用JQuery UI开发一个界面,这是javascript的一个框架,功能强大,界面漂亮. 首先要下载JQuery UI的包,引入里面的文件: <link href="jquery-ui.css" rel="stylesheet"> <script src="external/jquery/jquery.js"></script> <script src="jquery-ui.js&q

利用Jquery获取服务器端json数据

json (JavaScript Object Notation)是一种轻量级的数据交换格式,它使用的是的http get请求 通过jQuery的.getJSON()方法获取json数据,并转化为字符串 $.getJSON("/json/cats.json",function(json){        $(".message").html(JSON.stringify(json));      }); });