Results 1 to 2 of 2

Thread: cannot set json content-type in store

  1. #1
    Sencha User
    Join Date
    Dec 2009
    Vote Rating

    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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Gainesville, FL
    Vote Rating


    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
    Sencha Inc, Senior Software Engineer
    Learn BBCode and use it!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2

    Think my support is good? Get more personalized support via a support subscription.

    Need more help with your app? Hire Sencha Services

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Posting Permissions

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