关于ajax获取json数据返回到页面中!页面中显示不出来!
$.ajax({type:"POST",url:"CPSearch.action",data:paramStr,dataType:'json',success:funct...
$.ajax({
type: "POST",
url:"CPSearch.action",
data:paramStr,
dataType: 'json',
success: function (dataRes, textStatus, jqXHR) {
var result = dataRes.ResultInfo;
var debugInfo = dataRes.DebugInfo;
if(result != "error"){
function createShowingTable(dataRes){
var dataArray = $.parseJSON(dataRes.jsonData);
var tableStr = "<table>";
tableStr = tableStr +
"<thead><td>Casno</td><td>ChineseChemicalName</td><td>ChineseSynonyms</td><td>EnglishChemicalName</td><td>EnglishSynonyms</td><td>MolecularFormula</td></thead>";
var len = dataArray.length;
for(var i=0 ;i<len ; i++){
tableStr = tableStr
+ "<tr><td>"+ dataArray[i].Casno +"</td>"+"<td>"+dataArray[i].ChineseChemicalName + "</td>"+"<td>"+dataArray[i].ChineseSynonyms +"</td></tr>"
+ "<tr><td>"+ dataArray[i].EnglishChemicalName +"</td>"+"<td>"+dataArray[i].EnglishSynonyms + "</td>"+"<td>"+dataArray[i].MolecularFormula +"</td></tr>"
;
}
tableStr = tableStr + "</table>";
}
$("#scroll-box").html(tableStr);
}else{
alert("error cause by " + debugInfo);
}
},
error: function (dataRes) {
//alert("error cause by ajax error:" + dataRes.responseText );
}
});
} 展开
type: "POST",
url:"CPSearch.action",
data:paramStr,
dataType: 'json',
success: function (dataRes, textStatus, jqXHR) {
var result = dataRes.ResultInfo;
var debugInfo = dataRes.DebugInfo;
if(result != "error"){
function createShowingTable(dataRes){
var dataArray = $.parseJSON(dataRes.jsonData);
var tableStr = "<table>";
tableStr = tableStr +
"<thead><td>Casno</td><td>ChineseChemicalName</td><td>ChineseSynonyms</td><td>EnglishChemicalName</td><td>EnglishSynonyms</td><td>MolecularFormula</td></thead>";
var len = dataArray.length;
for(var i=0 ;i<len ; i++){
tableStr = tableStr
+ "<tr><td>"+ dataArray[i].Casno +"</td>"+"<td>"+dataArray[i].ChineseChemicalName + "</td>"+"<td>"+dataArray[i].ChineseSynonyms +"</td></tr>"
+ "<tr><td>"+ dataArray[i].EnglishChemicalName +"</td>"+"<td>"+dataArray[i].EnglishSynonyms + "</td>"+"<td>"+dataArray[i].MolecularFormula +"</td></tr>"
;
}
tableStr = tableStr + "</table>";
}
$("#scroll-box").html(tableStr);
}else{
alert("error cause by " + debugInfo);
}
},
error: function (dataRes) {
//alert("error cause by ajax error:" + dataRes.responseText );
}
});
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询