Jquery-同步载入数据
function getItem()
{
var str= $.ajax({ url: "Exec.aspx?flag="+Variables, async: false }).responseText;
var dom=new ActiveXObject("Microsoft.XMLDOM");
dom.loadXML(xml);
var t=dom.getElementsByTagName("item");
var menu=document.getElementById("Sele_City").options;
menu.length=0;
for(var i=0;i<t.length;i++)
{
menu.add(new Option(t[i].getAttribute("name"),t[i].getAttribute("id")));
}
}
-----------------------------------------------------------
<script runat="server">
void Page_Load(object sender, EventArgs e)
{
Response.ContentType = "text/xml";
Response.Write("<menus>");
Response.Write("<menu name=\"\" id=\"\" </menu>");
DataTable dt =new DataTable();
dt = (数据集);
foreach(DataRow dr in dt.Rows)
{
Response.Write("<menu name=\""+dr["name"].ToString()+"\" id=\""+dr["id"].ToString()+"\" </menu>");
}
Response.Write("</menus>";
}
</script>
{
var str= $.ajax({ url: "Exec.aspx?flag="+Variables, async: false }).responseText;
var dom=new ActiveXObject("Microsoft.XMLDOM");
dom.loadXML(xml);
var t=dom.getElementsByTagName("item");
var menu=document.getElementById("Sele_City").options;
menu.length=0;
for(var i=0;i<t.length;i++)
{
menu.add(new Option(t[i].getAttribute("name"),t[i].getAttribute("id")));
}
}
-----------------------------------------------------------
<script runat="server">
void Page_Load(object sender, EventArgs e)
{
Response.ContentType = "text/xml";
Response.Write("<menus>");
Response.Write("<menu name=\"\" id=\"\" </menu>");
DataTable dt =new DataTable();
dt = (数据集);
foreach(DataRow dr in dt.Rows)
{
Response.Write("<menu name=\""+dr["name"].ToString()+"\" id=\""+dr["id"].ToString()+"\" </menu>");
}
Response.Write("</menus>";
}
</script>