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>
posted @ 2008-01-13 22:26  南阳·源  阅读(3016)  评论(1编辑  收藏  举报