使用ajax是后台怎么样返回xml的

来源:百度知道 编辑:UC知道 时间:2024/07/01 04:50:19
我后台响应的是一个asp.net网页
我想让他回接到请求后在网页上显示出一个xml格式文档。好让我的前台处理。这要怎么做

string xml = "<responseXML>"+
"<name>test</name>"+
"</responseXML>"
// 清页面格式,写xml
Response.ClearContent();
Response.Cache.SetNoStore();
Response.ContentType = "text/xml";
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.Write(xml);

返回变量和返回xml不一样吗?直接把xml当字符串发到客户端嘛,

Ajax是使用HttpRequest(JavaScript)来实现的