Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

274
Visualizações
Extract text from input extjs and send it to php

I have a login with username and password, and a button with login. I want to send data from username and password to server-side PHP.

Ext.require([
    'Ext.form.Panel',
    'Ext.layout.container.Anchor'
]);

var log = Ext.onReady(function () {
    Ext.create('Ext.form.Panel', {
        renderTo: 'login',
        title: 'Login section',
        bodyPadding: '10 10 0',
        width: 300,
        fieldDefaults: {
            labelAlign: 'top',
            msgTarget: 'side'
        },
        defaults: {
            border: false,
            xtype: 'panel',
            flex: 1,
            layout: 'anchor'
        },

        layout: 'hbox',
        items: [{
            items: [{
                xtype: 'textfield',
                fieldLabel: 'User Name',
                anchor: '-5',
                name: 'first',
                id: 'userName'
            }, {
                xtype: 'textfield',
                fieldLabel: 'Password',
                anchor: '-5',
                name: 'password',
                inputType: 'password',
                id: 'password'
            }]
        }
        ],
        buttons: ['->', {
            text: 'Login',
            name: 'submit',
            /*listeners: {
             tap: function () {
             var form = Ext.getCmp('userName');
             //var values = form.getValues();
             Ext.Ajax.request({
             url: 'index.php',
             params: form,
             success: function (response) {
             var text = response.responseText;
             Ext.Msg.alert('asfasfaf', text);
             },

             failure: function (response) {
             Ext.Msg.alert('Error', 'Error while submitting the form');
             console.log(response.responseText);
             }

             });

             }
             }*/
            /* handler: function () {
             Ext.Ajax.request({
             url: 'index.php',
             method: 'POST',
             params: Ext.getCmp('userName').getValue(),
             success: function (response) {
             Ext.Msg.alert('success ' + Ext.getCmp('userName').getValue());
             },
             failure: function (response) {
             Ext.Msg.alert('server-side failure with status code ' + response.status);
             }
             });
             }*/
        },
            {
                text: 'Register?'

            }]
    });
});
over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

Ext.getCmp('userName').getValue();

over 4 years ago · Santiago Trujillo Relatório

0

You can use the Ext Form's submit method from within your button handler, e.g.:

// ....
buttons: [{
    text: 'Submit!',
    handler: function(btn) {
        btn.up('form').getForm().submit({
            url: 'mybackend.php',
            success: function(ret) {},
            failure: function(ret) {},
        });
    }
}],
// .....
over 4 years ago · Santiago Trujillo Relatório

0

I see that you have already tried to extract values and send request to php. May be this structure will help you. But you have to be sure that your php url accepts parameters with names 'param1' and 'param2' (or whatever your php accepts:) )

  {
     xtype : 'button',
     text :  "Submit"
     formBind : true,
     handler : function() {
        var userName = this.up('form').down('#userName');
        var password = this.up('form').down('#password');
        Ext.Ajax.request({
            url: url, // your php url
            method: 'POST',            
            params: {param1: userName, param2:password },           
            disableCaching: false,
            success:  function(response, opts)
            {
               var text = response.responseText; // for debugging print text and decodedText
               var decodedText = Ext.decode(text);
               if(decodedText.success)
               { 
               } 
             }
            failure: function() 
            {
            }
          });
         }
    }
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda