0
工作,我有一个Web服务,其以JSON格式返回数据内容类型在jQuery的
[WebMethod]
public string GetCustomers()
{
using (var documentStore = new DocumentStore { Url = "http://haseeb-pc:8080/" }.Initialize())
{
using (var session = documentStore.OpenSession())
{
var query = session.Query<Customer>().Select(customer => customer).Take(20);
var serializer = new JavaScriptSerializer();
return serializer.Serialize(query);
}
}
}
在jQuery中,当我使用:
contentType: "application/json; charset=utf-8",
我的萤火得到一个错误:
{"Message":"Invalid JSON primitive: take.","StackTrace":........................
当我删除此:
contentType: "application/json; charset=utf-8",
我的web服务给了我这样的XML:
<string xmlns="http://tempuri.org/">
[{"FirstName":"Human1","LastName":"Being1","Email":"myemail1","ProductInfo":{"Name":"product1","Quantity":10}}]
</string>
但是我希望结果是JSON?