Results 1 to 2 of 2

Thread: cannot set json content-type in store

  1. #1
    Sencha User
    Join Date
    Dec 2009

    Default cannot set json content-type in store

    I am using Ext 3.3.1 with .Net web service(asmx) as server.
    When I transfer data in xml format, it works great but when i move to json, it doesnt work.
    The problem is the Content-Type for both request and response is always set to "text/xml".
    I cannot get it to be "application/json".
    Can someone please give a code snippet showing how to set content type in a JsonStore config.
    The code below does not work..
    var proxy = new{
        method: 'POST',
        url: 'WebServiceTest.asmx/GetJson',
        headers: {
            'Content-Type': 'application/json;charset=utf-8'
    var store = new{
        proxy: proxy,
        root: 'd',
        idProperty: 'agencyId',
        fields: ['agencyId', 'name']
    If i use the following JQuery code, it works..
                  type: "POST",
                  contentType: "application/json; charset=utf-8",
                  url: "WebServiceTest.asmx/GetJson",
                  dataType: "json",
                  success: function(msg) {
                  var obj = jQuery.parseJSON(msg.d);
                    alert("Total: " + obj.Total);
    What will be the JsonStore equivalent for the above?

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


    With your code:

    var proxy = new{
        method  : 'POST',
        url     : 'data/json.json',
        headers : {
            'Content-Type' : 'application/json;charset=utf-8'
    var store = new{
        proxy      : proxy,
        root       : 'd',
        idProperty : 'agencyId',
        fields     : ['agencyId', 'name']
    running it in chrome I see the Content-Type header as is specified:

    Screen Shot 2013-04-22 at 9.19.17 AM.png
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:

    Posts are my own, not any current, past or future employer's.

Posting Permissions

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