1. #1
    Sencha User
    Join Date
    Jul 2012
    Posts
    5
    Vote Rating
    0
    mferraco is on a distinguished road

      0  

    Default Unanswered: Importing Data from JSON file to Store

    Unanswered: Importing Data from JSON file to Store


    I have begun developing an app where I use Sencha Touch for the frontend design and java to query the database on the backend. However, I am having trouble integrating the two together. I tried returning the data from a java query into a .json file in json format and then loading that into my app through a store but it doesn't seem to be working. I get the error in the Chrome console as shown below.



    I have my project contained in an eclipse Java Web Project so that I could easily utilize the localhost server. I am unsure as to why the json data is not loading into the store.

    Store:
    Code:
    
    
    Code:
    Ext.define('MyApp.store.Questions', {
        extend: 'Ext.data.Store',
        
        config: {
            autoLoad: true,
            model: 'MyApp.model.Question',
            
        proxy: {
            type: 'ajax', 
            url: 'localhost:8080/ProficyAppData/WebContent/app/store/info.json',
            reader: 'json'
        },
        listeners: {
            load: function() {
                console.log(this);
            }
        },
        }
    });
    
    
    Model:
    
    Ext.define('MyApp.model.Question', {
        extend: 'Ext.data.Model',
        
        config: {
            fields: ['id', 'criteria', 'description', 'questionName', 'type']
        }
    });
    
    
    info.json:
    
    [
         {
              "id": 1,
              "criteria": "no criteria yet",
              "description": "no description yet",
              "questionName": "no question yet",
              "type": "n/a"
         },
         {
              "id": 2,
              "criteria": "no criteria yet",
              "description": "no description yet",
              "questionName": "no question yet",
              "type": "n/a"
         },
         {
              "id": 3,
              "criteria": "no criteria yet",
              "description": "no description yet",
              "questionName": "no question yet",
              "type": "n/a"
         },
         {
              "id": 4,
              "criteria": "no criteria yet",
              "description": "no description yet",
              "questionName": "no question yet",
              "type": "n/a"
         },
         {
              "id": 5,
              "criteria": "no criteria yet",
              "description": "no description yet",
              "questionName": "no question yet",
              "type": "n/a"
         },
         {
              "id": 6,
              "criteria": "no criteria yet",
              "description": "no description yet",
              "questionName": "no question yet",
              "type": "n/a"
    
    
         }
    ]

  2. #2
    Sencha - Community Support Team jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364
    Vote Rating
    81
    Answers
    102
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default


    Moved to ST2 Q&A forums

  3. #3
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,548
    Vote Rating
    873
    Answers
    3567
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Are you getting any errors in the console like the CORS error? (noticed the port number in the url)
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    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.

  4. #4
    Sencha User
    Join Date
    Jul 2012
    Posts
    5
    Vote Rating
    0
    mferraco is on a distinguished road

      0  

    Default


    The only error I am getting in the console is the one I showed in the picture above. Is that what you mean?

  5. #5
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,548
    Vote Rating
    873
    Answers
    3567
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Quote Originally Posted by mferraco View Post
    The only error I am getting in the console is the one I showed in the picture above. Is that what you mean?
    The image you have there is within your gmail account and outsiders can't see it.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    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.

  6. #6
    Sencha User
    Join Date
    Jul 2012
    Posts
    5
    Vote Rating
    0
    mferraco is on a distinguished road

      0  

    Default


    Oh okay sorry here is the error I get in the chrome console.

    OPTIONS localhost:8080/ProficyAppData/WebContent/app/store/info.json_dc=1342618907990&page=1&start=0&limit=25 Resource failed to load

  7. #7
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,548
    Vote Rating
    873
    Answers
    3567
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Ok, yes, that is the browser trying to see if the server allows CORS (it does via an OPTIONS request) and your server isn't handling the OPTIONS request.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    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.

  8. #8
    Sencha User
    Join Date
    Jul 2012
    Posts
    5
    Vote Rating
    0
    mferraco is on a distinguished road

      0  

    Default


    Any idea on how to fix this? I don't have any prior knowledge on configuring a server to allow an OPTIONS request.

  9. #9
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,548
    Vote Rating
    873
    Answers
    3567
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    I'm not going to be able to support server configurations but Apache should allow it by default.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    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.

  10. #10
    Sencha User
    Join Date
    Jul 2012
    Posts
    5
    Vote Rating
    0
    mferraco is on a distinguished road

      0  

    Default


    But as far as you can see the code for the store and models looks correct?