Jquery 当asmx web服务返回时,我的JSON被包装成xml?
不幸的是,客户端只支持VS2008(框架3.5),不知道为什么我的json被包装成xml。使用webforms 我的JSON返回:Jquery 当asmx web服务返回时,我的JSON被包装成xml?,jquery,asp.net,json,.net-3.5,Jquery,Asp.net,Json,.net 3.5,不幸的是,客户端只支持VS2008(框架3.5),不知道为什么我的json被包装成xml。使用webforms 我的JSON返回: <?xmlversion="1.0"encoding="utf-8"?><stringxmlns="http://tempuri.org/">[ { "Name": "AAA", "Company": "AAAA", "Address": "AAAA", "Phone":
<?xmlversion="1.0"encoding="utf-8"?><stringxmlns="http://tempuri.org/">[
{
"Name": "AAA",
"Company": "AAAA",
"Address": "AAAA",
"Phone": "1204675",
"Country": "US"
},
{
"Name": "AAAA",
"Company": "AAAA",
"Address": "AAAA",
"Phone": "AAA",
"Country": "AAA"
}
]</string>
这可能会对您有所帮助:我的问题没有解决方案。是否包括相关的web.config部分?
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class HCTCService : System.Web.Services.WebService
{
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string TestJSON()
{
Employee[] e = new Employee[2];
e[0] = new Employee();
e[0].Name = "AAA";
e[0].Company = "AAAA";
e[0].Address = "AAAA";
e[0].Phone = "1204675";
e[0].Country = "US";
e[1] = new Employee();
e[1].Name = "AAAA";
e[1].Company = "AAAA";
e[1].Address = "AAAA";
e[1].Phone = "AAA";
e[1].Country = "AAA";
return new JavaScriptSerializer().Serialize(e);
}
}
}