jquery 读取数据库已XML格式返回数据

microsoftAnson 2010-07-19 01:58:21
jquery 读取数据库已XML格式返回数据,在网上找了很多东西 不能用,希望各位大虾,帮忙,很急在线等。
...全文
125 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
njlywy 2010-07-19
  • 打赏
  • 举报
回复
学习…
hahanan1987 2010-07-19
  • 打赏
  • 举报
回复
$.ajax({
type: "GET",
url: url[0] + "?id=" + document.getElementById(obj).options[document.getElementById(obj).selectedIndex].value,
dataType: "xml",
success: function(msg){
optionlist = msg.getElementsByTagName ("option");
for(var ii = 0 ; ii<optionlist.length; ii++){
var optionnode = createOption(optionlist[ii].childNodes[1].childNodes[0].nodeValue, optionlist[ii].childNodes[0].childNodes[0].nodeValue);
ddlZone.appendChild(optionnode);
}
}
});
几个关键参数设下 dataType设成xml 这样返回的msg jquery会自动包装成xml
后台的这样输出
Response.Clear();
Response.ContentType = "text/xml";
Response.Charset = "UTF-8";
Response.Write("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
Response.Write(xml); //你的xml Response.End();
myhope88 2010-07-19
  • 打赏
  • 举报
回复
<?xml version="1.0" encoding="UTF-8" ?>
<entries>
<entry term="DANCE" part="v.i.">
<definition>
To leap about to the sound of tittering music,preferably with arms about your neghbor's wife or daughter.There are many kinds of dances,but all those requiring the participation of the two sexes have two characteristics in common:they are conspicuously innocent,and warmly loved by the vicious.
</definition>
</entry>
<entry term="DAY" part="n.">
<definition>
A period of twenty-four hours,mostly misspent.This period is divided into two parts,the day proper and night,or day improper<![CDATA[—]]>the former devoted to sins of business,the latter consecrated to the other sort.These two kinds of social activity overlap.
</definition>
</entry>
<entry term="DEBT" part="n.">
<definition>
An ingenious substitute for the chain and whip of the slave-driver.
</definition>
<quote author="Barlow $. Vode">
<line>As,pent in an auarium,the troulet</line>
<line>Swims round and round his tank to find an outlet,</line>
<line>Pressing his nose against the glass that holds him,</line>
<line>Nor ever sees the prisom that enfolds him;</line>
<line>So the poor debtor,seeing naught around him,</line>
<line>Yet feels the narrow limits that impound him,</line>
<line>Grieves at his debt and studies to evade it,</line>
<line>And finds at last he might as well have paid it.</line>
</quote>
</entry>
<entry term="DEFAME" part="v.t.">
<definition>
To line about another,To tell the truth about another.
</definition>
</entry>
</entries>

这个xml文件,都可以,不知道楼主怎么处理的
myhope88 2010-07-19
  • 打赏
  • 举报
回复
$.get('d.xml',function(data){

$('#dictionary').empty();
$(data).find('entry').each(function(i){
var $entry=$(this);
var html='<div class="entry">';
html+='<h3 class="term">'+$entry.attr('term')+'</h3>';
html+='<div class="part">'+$entry.attr('part')+'</div>';
html+='<div class="definition">';
html+=$entry.find('definition').text();
var $quote=$entry.find('quote');
if($quote.length){
html+='<div class="quote">';
$quote.find('line').each(function(j){
html+='<div class="quote-line">'+$(this).text()+'</div>';
});
if($quote.attr('author')){
html+='<div class="author">'+$quote.attr('author')+'</div>';
}
html+='</div>';
}
html+='</div>';
html+='</div>';
$('#dictionary').append(html);
});
});
KevinLee_1983 2010-07-19
  • 打赏
  • 举报
回复
用get 或 post呀,callback里可以读到你要的数据呀。
你打断点看一下后台code里是否能正确返回。

62,040

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧