jquery php mysql和json返回循环数据
我以前从未尝试过,我的解决方案也不起作用 在mysql中,我可以使用while循环编写它,但我试图通过ajax提取数据 有人能帮忙吗jquery php mysql和json返回循环数据,php,jquery,mysql,Php,Jquery,Mysql,我以前从未尝试过,我的解决方案也不起作用 在mysql中,我可以使用while循环编写它,但我试图通过ajax提取数据 有人能帮忙吗 var qString = 'country=' +country+'&continent='+continent; $.post('/assets/inc/get-country.php', qString, function (data) { $('#'+continent).append('<li>'+data[0].c
var qString = 'country=' +country+'&continent='+continent;
$.post('/assets/inc/get-country.php', qString, function (data) {
$('#'+continent).append('<li>'+data[0].country+' '+data[0].company+'</li>');
}, "json");
如何将其显示为页面上的li列表
提前谢谢
编辑
$(“#注释选项卡分区a”)。单击(功能(e){
e、 预防默认值();
var contraction=$(this.parent().attr(“id”);
var country=$(this.attr(“名称”);
console.log(大陆+国家);
var qString='country='+country+'&continument='+continument;
$.post('/assets/inc/get country.php',qString,函数(数据){
用于(数据中的公司编号){
$(“#”+大陆)。追加(“”+数据[公司编号]。国家+”+数据[公司编号]。公司+” )
}
}“json”);
});
只需在javascript中循环即可:
function (data)
{
for(company_nr in data)
{
$('#'+continent).append('<li>'+data[company_nr].country+' '+data[company_nr].company+'</li>')
}
}
功能(数据)
{
用于(数据中的公司编号)
{
$(“#”+大陆)。追加(“”+数据[公司编号]。国家+”+数据[公司编号]。公司+” )
}
}
$("#comments-tabs div.country a").click(function(e){
e.preventDefault();
var continent = $(this).parent().attr("id");
var country = $(this).attr("name");
console.log(continent+country);
var qString = 'country=' +country+'&continent='+continent;
$.post('/assets/inc/get-country.php', qString, function (data) {
for(company_nr in data){
$('#'+continent).append('<li>'+data[company_nr].country+' '+data[company_nr].company+'</li>')
}
}, "json");
});
function (data)
{
for(company_nr in data)
{
$('#'+continent).append('<li>'+data[company_nr].country+' '+data[company_nr].company+'</li>')
}
}