1. #1
    Sencha User
    Join Date
    Nov 2013
    Posts
    14
    Vote Rating
    0
    benny_GI is on a distinguished road

      0  

    Default Unanswered: Get/Send value from/to Database

    Unanswered: Get/Send value from/to Database


    hello, i'm new in working with ExtJs and my english is terrible, so i hope you can understand me.

    i've two questions/problems:

    #1
    i have a textfield and want to set this value with data from database.

    #2
    i have a textfield and want to send this value as a request to database, with click on a button. after that i want to handle the answer from database.

    how can i do this? does it anybody know? so let me know too

    thanks

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,998
    Answers
    665
    Vote Rating
    456
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      1  

    Default


    Have a look at at ajax request:

    Code:
    Ext.Ajax.request({
        url: 'page.php',
        params: {
            id: 1 // send value
        },
        success: function(response){
            var text = response.responseText;
            // process server response here
        }
    });

  3. #3
    Sencha User
    Join Date
    Nov 2013
    Posts
    14
    Vote Rating
    0
    benny_GI is on a distinguished road

      0  

    Default


    thanks, for your answer. i tried your answer, like this:
    Code:
         var rest=my.rest=new Ext.create('Ext.Ajax.request',{      
     url:config.server+'/?login',       
    params: {         
    name:my.nutzer.items.items[1].value,          
    pw:my.passwort.items.items[1].value       
    }     
    });
    But i get an error: Uncaught TypeError: Object [object Object] has no method 'fireEvent'

    What's wrong? Can you help, please?

  4. #4
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,998
    Answers
    665
    Vote Rating
    456
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    Please see the syntax for using ajax: (or as I have shown)
    http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.Ajax

    In your code you have new Ex.create(...)

    It would be either:
    Code:
    new Ext.panel.Panel({ .. })
    Code:
    Ext.create('Ext.panel.Panel', {..})
    Also, check your objects that you are assigning to params to see if they are valid.

    You may want to also query the object for child items instead using object.items.items[1].value
    Code:
    Ext.application({
        name: 'Fiddle',
    
        launch: function() {
    
            var form = Ext.create('Ext.form.Panel', {
                title: 'Simple Form',
                bodyPadding: 5,
                width: 350,
    
                layout: 'anchor',
                defaults: {
                    anchor: '100%'
                },
    
                defaultType: 'textfield',
                items: [{
                    fieldLabel: 'First Name',
                    name: 'first',
                    itemId: 'first-name',
                    allowBlank: false,
                    value: 'Sencha'
                }, {
                    fieldLabel: 'Last Name',
                    name: 'last',
                    itemId: 'field-lname',
                    allowBlank: false
                }],
    
                renderTo: Ext.getBody()
            });
    
            // query form for field
            var firstName = form.down('#first-name');
            console.log(firstName);
    
            console.log(firstName.getValue());
    
        }
    });
    Code:
    Ext.Ajax.request({
        url : config.server + '/?login',
        params : {
            name : firstName.getValue()
        },
        success: function(response){ .. }
    });

  5. #5
    Sencha User
    Join Date
    Nov 2013
    Posts
    14
    Vote Rating
    0
    benny_GI is on a distinguished road

      0  

    Default


    thanks for your answer.
    i put the Ext.Ajay.request(); in a handler from button.

    Code:
     
        var anmelden = new Ext.create('Ext.Button',{
          minWidth: 42,
          minHeight: 42,
          handler: function() {
            if(my.nutzer.items.items[1].value !== undefined || my.passwort.items.items[1].value !== undefined){
              Ext.Ajax.request({
                url: config.server+'/?login',
                params: {
                  name:my.nutzer.items.items[1].value, 
                  passwort:my.passwort.items.items[1].value 
                },
                success: function(response){
                  var text = response.responseText;
                  alert('request successful: '+text);
                }
              });
            }
            else {  
              alert('Eingabe fehlerhaft!');
            }
          }
        });
    so i got a request, but no content, but i think it's a problem of php, isn't it?

  6. #6
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,998
    Answers
    665
    Vote Rating
    456
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    Most likely .. you would send info back. You can test with

    Code:
    <?php
    
        echo '{ success: true }';
    
    ?>

  7. #7
    Sencha User
    Join Date
    Nov 2013
    Posts
    14
    Vote Rating
    0
    benny_GI is on a distinguished road

      0  

    Default


    ok i tried, but nothing changed.
    [ATTACH=CONFIG]remove[/ATTACH]

    Unbenannt.png
    Attached Images

  8. #8
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,998
    Answers
    665
    Vote Rating
    456
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    See if the following helps:

    Code:
    Ext.application({
        name : 'Fiddle',
    
        launch : function() {
            
            Ext.Ajax.request({
                url : 'login.php',
    
                params : {
                    name : 'Sencha'
                },
                
                success: function(response){
                  var text = response.responseText;
                  console.log('request successful: ' + text);
                }
            });        
            
        }
    });
    Code:
    <?php
    
        $name  = $_REQUEST['name'];
    
        $return = array(
            'success' => TRUE,
            'data'    => '{ name: ' . $name . '}'
        );
          
        $return = json_encode($return);
        echo $return;  
        
    ?>
    output:
    Code:
    request successful: {"success":true,"data":"{ name: Sencha}"}

  9. #9
    Sencha User
    Join Date
    Nov 2013
    Posts
    14
    Vote Rating
    0
    benny_GI is on a distinguished road

      0  

    Default


    sorry, but it doesn't help me further

Thread Participants: 1

Tags for this Thread