Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: [SOLVED] Problem Loading Form JsonReader

  1. #1

    Default [SOLVED] Problem Loading Form JsonReader

    Do not load values in fields...
    I can't find what might be problem. Help me...

    PHP Code:
    var formEdit = new Ext.form.FormPanel({
                
    width 450,
                
    region'center',
                
    labelAlign 'right',
                
    id camelize(title),
                
    bodyStyle 'padding-top: 10px',
                
    defaults : { allowBlank false },
                
    items : [{
                    
    xtype 'textfield',
                    
    fieldLabel 'Nome',
                    
    name 'name',
                    
    id 'name',
                    
    anchor '80%'
                
    },
                {
                    
    xtype 'textfield',
                    
    fieldLabel 'Email',
                    
    name 'email',
                    
    id 'email',
                    
    anchor '80%'
                
    }],
                
    reader : new Ext.data.JsonReader({
                    
    root 'formEdit'
                
    },
                [{
    name 'name'mapping'name'}, {name 'email'mapping'email'}]),
                
    buttons: [{
                    
    text 'Salvar'
                    
                
    },{
                    
    text 'Fechar',
                    
    handler : function(){ windows.Content.close(); }
                }]
            });
            
            
    windows.Content.add(formEdit);
            
    windows.Content.setSize(450150);
            
    windows.Content.show(this);
            
    formEdit.getForm().load({url:'php/url.php'waitMsg:'Carregando informações...'}); 
    This is the data sent back
    {success:true,"formEdit":{"name":"PAULO VITOR","email":"paulovitin@gmail.com"}}
    Thanks!!

  2. #2
    Ext User
    Join Date
    Mar 2008
    Location
    Houston, TX
    Posts
    148

    Default

    JSON is bad...

  3. #3

    Default

    Quote Originally Posted by rvent View Post
    JSON is bad...
    how so?

  4. #4
    Ext User
    Join Date
    Mar 2008
    Location
    Houston, TX
    Posts
    148

    Default

    Error:
    Problem at line 1 character 2: Expected a string and instead saw success.

    {success:true,"formEdit":{"name":"PAULO VITOR","email":"paulovitin@gmail.com"}}

    http://jslint.com/

  5. #5

    Default

    Quote Originally Posted by rvent View Post
    Error:
    Problem at line 1 character 2: Expected a string and instead saw success.

    {success:true,"formEdit":{"name":"PAULO VITOR","email":"paulovitin@gmail.com"}}

    http://jslint.com/
    Now JSON is GOOD, but no worked... Is now?
    { "success" : true, "formEdit" : {"name" : "PAULO VITOR", "email" : "paulovitin@gmail.com" } }

  6. #6
    Ext User
    Join Date
    Mar 2008
    Location
    Houston, TX
    Posts
    148

    Default

    Show the code that forms your JSON...

  7. #7

    Default

    Quote Originally Posted by rvent View Post
    Show the code that forms your JSON...
    No exist code. I wrote this to test...

    I Checked in http://jslint.com/. It is good now.

  8. #8
    Ext User
    Join Date
    Mar 2008
    Location
    Houston, TX
    Posts
    148

    Default

    ok, you dont need mapping if the names of the fields are the same...

    also, how do you know that you are getting that JSON..? did you copy that from firebug...?

    how is that JSON getting to the browser...? This is your line of code: formEdit.getForm().load({url:'php/url.php'

    whats is the contents of php/url.php....?

  9. #9

    Default

    Quote Originally Posted by rvent View Post
    ok, you dont need mapping if the names of the fields are the same...

    also, how do you know that you are getting that JSON..? did you copy that from firebug...?

    how is that JSON getting to the browser...? This is your line of code: formEdit.getForm().load({url:'php/url.php'

    whats is the contents of php/url.php....?
    php/url.php
    PHP Code:
    <?
    echo "{'success':true, 'formEdit':{'name' : 'PAULO VITOR', 'email' : 'paulovitin@gmail.com'}}";
    ?>
    Attached Images Attached Images

  10. #10
    Ext User
    Join Date
    Mar 2008
    Location
    Houston, TX
    Posts
    148

    Default

    the "JSON" you are echoing is bad...

Page 1 of 2 12 LastLast

Posting Permissions

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