日期:2014-05-17  浏览次数:20387 次

asp.net 异步更新jquery.$.ajax方法
 function strings() {
            alert(6666);
            try {
                $.ajax({
                    type: "GET",
                    url: "Json.aspx",
                    dataType: "xml",
                    contentType: "application/xml;charset=utf-8",
                    success: function (xml) {
                        $("TextBox2").value = $(xml).find("resultString").children("text1").text();
                        var id = $(xml).find("resultString").children("text1").text();
                        alert(id);


                    },
                    error: function () { alert("出错了") }
                });
            }
            catch (e) {
                throw e;
            }
            alert(44444);
        }

转入到json.aspx页后访问xml,然后读取xml,结果总是提示出错了(json也代码运行后);
json页代码如下:
  protected void Page_Load(object sender, EventArgs e)
    {
        Response.Write(11111);
    
      Response.ContentType = "text/xml";
      Response.Charset = "utf-8";
      Response.Write( resultString());
      Response.End();

    }
    public string aa;
    public string resultString()
    {
        StringBuilder result = new StringBuilder();
        result.Append("<?xml version='1.0' encoding='utf-8'?>");
        result.Append("<Alltext>");
        result.Append("<text1>