Results 1 to 2 of 2

Thread: loading Store from raw JSON string

  1. #1

    Default loading Store from raw JSON string

    Folks,

    I could not figure out how to parse JSON data arriving via Ajax call. I got plain response data and thought that I could use Store reader to read data and create Store records, however nothing was created. Is it a way to load Store using JSON string obtained via raw Ajax call ?



    // definition of the data store
    Ext.define('Mint.store.UserProfileRequestStore', {
    extend: 'Ext.data.Store',
    requires: [
    'Mint.model.UserProfileRequest'
    ],

    config: {

    model: 'Mint.model.UserProfileRequest',
    storeId: 'UserProfileRequestId',

    proxy: {
    reader: {
    type:'json',
    successProperty: 'userProfile'

    }
    }
    },

    // data are brought via following call

    Ext.Ajax.request ({
    jsonData: '{ "getUserProfile": {} }',
    headers: {
    Authorization: 'ggggg"', //window.mint.getAuthenticationString(),
    },
    dataType:'json',
    url: "http://xxxxx"

    success:function(response,opt){
    var data=response.responseText;

    Ext.Msg.alert('Title','Success:' + data.substr(0, 5));
    var store = Ext.getStore('UserProfileRequestId');
    store.parseData(data);


    },
    failure:function(res,opt){
    Ext.Msg.alert('Title','Connection Failed:' + res);
    console.log(res);



    // Parsing data

    parseData: function(data) {

    var reader = this.getProxy().getReader();
    alert("Temp:" + reader);
    reader.read(data);
    var foo = this.getAt(0);
    alert("Foo:" + foo);




    }

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,379
    Answers
    3997

    Default

    Why are you loading it with Ext.Ajax? Why not let the proxy in the store do the loading?
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    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
  •