Results 1 to 2 of 2

Thread: JSON Being Returned from asmx web service ScriptMethod

  1. #1
    Sencha User
    Join Date
    Nov 2011
    Vote Rating

    Default JSON Being Returned from asmx web service ScriptMethod

    I have created a c# web service to return JSON for some of our SharePoint data. Below is the web service code:

    [ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = true, XmlSerializeString = false)]
    public string GetJSON() {
    ExecutiveTeamDataContext dc = new ExecutiveTeamDataContext(new Uri(""));
    dc.Credentials = new NetworkCredential("xxxxx", "xxxxx", "xx");
    var items = from c in dc.WorkgroupTasks where c.Id == 10
    select new
    TaskID = c.Id,
    TaskTitle = c.Description1,
    TaskNextAction = c.NextActionStatus,

    JavaScriptSerializer js = new JavaScriptSerializer();
    string strJson = js.Serialize(items);
    return strJson;

    Following is what is being returned to sencha

    {"d":"[{\"TaskID\":10,\"TaskTitle\":\"\u003cdiv\u003eAnalysis of Capital Accounts\u003c/div\u003e\",\"TaskNextAction\":\"\u003cdiv\u003eUse model to develop presentation to bonding company.\u003c/div\u003e\"}]"}

    Here is the code I used to read the response
    fullscreen: true,
    glossOnIcon: false,
    onReady: function ()
    // to test the call
    url: 'https://mobile.*****.com/spclient/webservice.asmx/GetJSON',
    method: 'GET',
    jsonData: { "Alert": {} },
    headers: { 'Content-Type': 'application/json;charset=utf-8'
    success: function (response, opts)
    failure: function (response, opts)

    Finally, here is the code I am using to try to bind the data. When it runs, I get a count in the console of 193 records, even though the web service is returning only the one record shown above. Also, nothing is displayed in the grid, just 193 empty rows. My guess is that it has something to do with the " directly after "d" : " since many of the examples I have seen do not include this. So if the root is d, it seems like everything else is being wrapped in an extra pair of quotes.

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Gainesville, FL
    Vote Rating


    Is this 193 characters long? Did you decode it via Ext.decode(response.responseText) ?
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts