Search code examples
ajaxextjssencha-touch-2

Accessing the information in build.settings through an ajax request


So I know you can use json files to load data into a store, but I was wondering if there exists a way to make a request to only access a single "variable", in a similar way Ux.Locale.Manager works.

To be more specific, I'm working with an app built on Sencha Architect, and I would like one of the views to contain the version of the app. While I could just hardcode that label and update it every time I make a build, I was wondering if it was possible to just access the information in the build.settings file, specifically the versionString and versionCode variables, to make things easier? And if possible, how would I go about making an ajax request without involving a Model and a Store?


Solution

  • I figured it out. I kept thinking I had to make a call with an AjaxProxy, but a simple Ext.Ajax.request did the trick:

    Ext.Ajax.request({
        url: 'build.settings',
        method: 'GET',
        success: function(response, opts){
            var data = JSON.parse(response.responseText);
            Ext.getCmp('appVersion').setHtml("version " + data.androidBuild.versionString + "." + data.androidBuild.versionCode);
        }
    });