Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/05/2013, 14:58
ambichol
 
Fecha de Ingreso: febrero-2013
Ubicación: Lima
Mensajes: 301
Antigüedad: 11 años, 2 meses
Puntos: 5
Pregunta como enviar variables desde un archivo .js

hola, necesito su apoyo con un tema en concreto, deseo saber como hacer que un archivo ext.js envie variables, y que una pagina en php los recepcione. comparto el codigo para que me puedan ayudar, y se los agradeceria bastante......
Código Javascript:
Ver original
  1. Ext.QuickTips.init();
  2.  
  3. Ext.onReady(function(){
  4.  
  5.     var fp = new Ext.FormPanel({
  6.         id: 'status-form',
  7.         renderTo: Ext.getBody(),
  8.         labelWidth: 75,
  9.         frame: true,
  10.         monitorValid:true,
  11.         width: 350,
  12.         buttonAlign: 'right',
  13.         border: false,
  14.         bodyStyle: 'padding:10px 10px 0;',
  15.         defaults: {
  16.             anchor: '95%',
  17.             allowBlank: false,
  18.             selectOnFocus: true,
  19.             msgTarget: 'side'
  20.         },
  21.         items:[{
  22.             xtype: 'textfield',
  23.             fieldLabel: 'Login',
  24.             id: 'login',
  25.             name: 'login',
  26.             minLength: 2,
  27.             blankText: 'Ingrese su Usuario'
  28.         },{
  29.             xtype: 'textfield',
  30.             fieldLabel: 'Password',
  31.             id: 'password',
  32.             name: 'password',
  33.             minLength: 2,
  34.             inputType: 'password',
  35.             allowBlank:false,
  36.             blankText: 'Ingrese su Clave'
  37.         }],
  38.         buttons: [{
  39.             text: 'Ingresar',
  40.             visible: false,
  41.             handler: function(){
  42.                 if(fp.getForm().isValid()){
  43.                     var sb = Ext.getCmp('form-statusbar');
  44.                     sb.showBusy('Validando...');
  45.                     fp.getEl().mask();
  46.                     fp.getForm().submit({
  47.                         url: 'fake.php',
  48.                         success: function(){
  49.                             sb.setStatus({
  50.                                 text:'Validacion Completa::::Bienvenido...!',
  51.                                 iconCls:'',
  52.                                 clear: true
  53.                             });
  54.                             fp.getEl().unmask();
  55.                             var redirect = "../../Main2/index.php";
  56.                             window.location = redirect;
  57.                         }
  58.                     });
  59.                 }
  60.             }
  61.         },{
  62.             text: 'Cancelar',
  63.             visible: false
  64.             }]
  65.     });
  66.  
  67.     //Ext.getCmp('login').focus(); // El foco estara puesto en el campo id
  68.    
  69.     new Ext.Panel({
  70.         title: 'Ingrese Datos',
  71.         renderTo: Ext.getBody(),
  72.         width: 350,
  73.         autoHeight: true,
  74.         layout: 'fit',
  75.         items: fp,
  76.         bbar: new Ext.ux.StatusBar({
  77.             id: 'form-statusbar',
  78.             defaultText: 'Ingrese Datos',
  79.             plugins: new Ext.ux.ValidationStatus({form:'status-form'})
  80.         })
  81.     });
  82.  
  83. });

fake.php
Código PHP:
Ver original
  1. <?php
  2. include "../../Conexion/cnx_php.php";
  3. //obtenemos los valores de nuestro login
  4. $user = $_POST['Login'];
  5. $pass = $_POST['password'];
  6. $result = mssql_query("select [login],[password] from SRM_LOGIN where login= '$user' and password = '$pass'");
  7. $row = mssql_fetch_array($result);
  8.  
  9. //Realiza la validacion de Usuarios
  10.  
  11. if($row['Login'] == $user && $row['password'] == $pass){
  12.      echo "{success:true}";
  13. }else{
  14.      //echo "{success:false, errors: { reason: 'Password error.' }}";
  15.      echo "{success:false}";
  16.     }
  17. ?>