Results 1 to 4 of 4

Thread: Empty store variable after ajax call

  1. #1
    Sencha User
    Join Date
    Apr 2019
    Posts
    4
    Vote Rating
    0
      0  

    Default Empty store variable after ajax call

    Dear all,

    I have an instance of the Ext.data.Store class:

    var myStore = Ext.create('Ext.data.Store', {
    model: 'Modello',
    proxy: {
    type: 'ajax',
    url: 'com/database/azienda2.jsp',
    reader: {
    type: 'json',
    root: 'data'
    }
    },
    autoLoad: true
    });

    but this variable seems to be empty. Indeed, store.count() gives 0 as output.
    How this can be possible? I need to loop on each store record to get record name.
    How can I solve this problem?
    Thanks,

    Saverio

  2. #2
    Sencha Premium User danguba's Avatar
    Join Date
    Feb 2009
    Location
    Kragujevac, Serbia
    Posts
    462
    Vote Rating
    230
      1  

    Default

    If I assume that your server response is fine (believe it or not this is a most common problem) then maybe you are trying to access data before it is actually loaded. Ajax proxy is using AJAX and thus is asynchronous so you have to wait for store to finish loading before you can access it's data. Take a look at this fiddle https://fiddle.sencha.com/#view/editor&fiddle/2rl6
    All Best
    ---
    Željko Mitrović
    http://skitanja.blogspot.com/

    "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." Martin Golding

  3. #3
    Sencha User
    Join Date
    Apr 2019
    Posts
    4
    Vote Rating
    0
      0  

    Default

    Thank you so much!!!
    It works!
    I used my store after loaded in the load event function!

  4. #4
    Sencha Premium User danguba's Avatar
    Join Date
    Feb 2009
    Location
    Kragujevac, Serbia
    Posts
    462
    Vote Rating
    230
      0  

    Default

    I'm glad I was able to help you
    All Best
    ---
    Željko Mitrović
    http://skitanja.blogspot.com/

    "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." Martin Golding

Tags for this Thread

Posting Permissions

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