【发布时间】:2011-07-14 09:01:30
【问题描述】:
脚本
$.ajax({
type: "post",
url: "Default.aspx?cmd=Setting",
success: parseXml
});
function parseXml(xml)
{
alert(xml);//show Full XML File
//find every Tutorial and print the author
$(xml).find("Tutorial").each(function()
{
$("#a").append($(this).attr("author") + "<br />");
});
}
HTML
<div id="a"></div>
代码
protected void Page_Load(object sender, EventArgs e)
{
if (Request["cmd"] == "Setting")
{
string k=@"<?xml version='1.0' encoding='utf-8' ?>
<RecentTutorials>
<Tutorial author='The Reddest'>
<Title>Silverlight and the Netflix API</Title>
<Categories>
<Category>Tutorials</Category>
<Category>Silverlight 2.0</Category>
<Category>Silverlight</Category>
<Category>C#</Category>
<Category>XAML</Category>
</Categories>
<Date>1/13/2009</Date>
</Tutorial>
</RecentTutorials>";
Response.Write(k );
Response.End();
}
}
我是初学者。
这不起作用。
while alert(xml) 显示 xml 文件。
【问题讨论】:
-
请定义“不起作用”。
-
你试过
alert(xml);里面的parseXml -
显示 xml 但不附加到 div
标签: asp.net xml jquery xmlhttprequest