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?