I am trying to make a web service method call in JavaScript within an ASP.NET 3.5 environment.
After inspecting the result using Firebug, I found the following:
{"d":"[{\"TI\":\"www\"},{\"TI\":\"www1\"}]"}
It seems that the correct result should be formatted like this:
{"d":[{\"TI\":\"www\"},{\"TI\":\"www1\"}]}
Why is there a quotation mark before and after the brackets?
// Update:
public class Test
{
public Test(string t){T1 = t;}
public string T1 { set; get; }
}
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = true, XmlSerializeString = false)]
public string Load(string e)
{
List<Test> post = new List<Test> { new Test("www"), new Test("www1") };
return JsonConvert.SerializeObject(post);
}
And in the JavaScript file:
var store = new Ext.data.JsonStore({
proxy: new Ext.data.HttpProxy({
url: '/core/webservice/service.asmx/Load',
method: 'GET',
headers: { 'Content-type': 'application/json' }
}),
root: 'd',
id: 'Id',
fields: ['TI']
});
store.load({ params: { e: ''} });
return;
Thank you,
Mir