Results 1 to 5 of 5

Thread: Ext.Model can't get data from remote server

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Ext JS Premium Member
    Join Date
    Aug 2011
    Posts
    6
    Vote Rating
    0
      0  

    Default Unanswered: Ext.Model can't get data from remote server

    this is my code:

    Code:
    Ext.regModel('UserTask', {
        fields: ['ret_code', 'ret_desc'],
    proxy:{
    type:'ajax',
            url: 'http://localhost/api.php',
    reader: 'json'
        },
    
    });
    
    var user3=Ext.ModelMgr.getModel('UserTask');
    user3.load(null, {
        success: function(record, operation) {
            console.log(record);
            console.log(operation);
        }
    });
    remote server response text is :
    {"ret_code":"SUCC","ret_desc":"","task":"abc"}


    the result return is :
    record is undefined

  2. #2
    Sencha User
    Join Date
    Aug 2010
    Posts
    311
    Answers
    4
    Vote Rating
    5
      0  

    Default

    I dont see any store in your code, you need a model and store, you are mixing model and store param in your model definition...

  3. #3
    Ext JS Premium Member
    Join Date
    Aug 2011
    Posts
    6
    Vote Rating
    0
      0  

    Default

    thanks your reply

    store is multiple Model.
    i just want to load one record to Model, not a store

    i read the docs api (http://dev.sencha.com/deploy/touch/docs/), the example code in "Using Proxy" can resolve my question, but do not work.

  4. #4
    Ext JS Premium Member
    Join Date
    Aug 2011
    Posts
    6
    Vote Rating
    0
      0  

  5. #5
    Sencha - Services Team
    Join Date
    Mar 2007
    Location
    Foristell, MO
    Posts
    1,113
    Answers
    13
    Vote Rating
    5
      0  

    Default

    The issue is with your server's response. When you load data into a store the data needs to be an Array of whatever you are loading. So if you are loading in Json, you need an array of json objects. So just wrap your response in square brackets and then your code will work.
    Jack Ratcliff
    Sencha Inc, Green bleeding Senchan

    How to report a bug:
    http://www.sencha.com/forum/showthre...o-report-a-bug

Posting Permissions

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