(ext js 3.3 kullanarak) ext deposundan json görüntüleyemezsiniz

0 Cevap php

ben bu php kodu var:


<?php $account = $_POST['ac'];
  $amount = $_POST['y']; 
  $percent = $amount*0.01;
  $sum = $amount + $percent;
// Encoding to JSON 
$json_data = array ('account'=>$account, 'amount'=>$amount, 'percent'=>$percent, 'sum'=>$sum);
?><br/>
<? if (isset($_POST['final'])) { ?>
 say sth
<? } else { 
//here we must send ready json 
echo json_encode($json_data);
} 
?>

ve ben bu kod js dosyası vardır:


Ext.onReady(function () {

 Ext.form.Field.prototype.msgTarget = 'side';

    var bd = Ext.getBody();

    var mainForm = new Ext.FormPanel({
        labelWidth: 150, 
        url: 'save-form.php',
        border: false,
        bodyStyle: 'padding:5px 5px 0; margin:10px 20px 20px 10px',
        width: 450,
        defaults: { width: 250 },
        defaultType: 'textfield',
        monitorValid: true,

        items: [
            {
                xtype: 'panel',
                border: false,
                width: 450,
                height: 130,
                bodyStyle: 'background: url(../images/Logo/Kcell.png) no-repeat; margin-left:150px'
            }, {
                xtype: 'displayfield',
                value: '<br><font color=red><b>Âíèìàíèå!</b></font> <i>Êîë-âî íå ìîæåò áûòü ìåíüøå 100 óå è íå áîëåå 50 000 óå.<i><br><br>',
                width: 280
            }, {  
                fieldLabel: 'Íîìåð òåëåôîíà',
                name: 'account',
    id:'account',
                xtype: 'numberfield',
                allowBlank: false,
                autoCreate: {tag: 'input', maxlength: '10'},
                maskRe: '/[0-9\.]/',
                regex: new RegExp('(701)|(702)|(775)[0-9]{7}'),
                regexText: 'Íîìåð äîëæåí áûòü ñëåäóþùåãî ôîðìàòà: 701/702/775 ÕÕÕÕÕÕÕ.'
   },{  
                fieldLabel: 'Ñóììà â óå',
                name: 'amount',
    id:'amount',
                xtype: 'numberfield',
                allowBlank: false
   }
        ],
        buttons: [{
            text: 'Îáìåíÿòü',
            formBind: true,
            handler  : function(){
       var ac = mainForm.get('account').getValue(false);
    var y = mainForm.get('amount').getValue(false);
    //alert(ac+' '+y);
    Ext.Ajax.request({
       url: './res.php',
       method: 'POST',
       success: function(response) {
        mainForm.setVisible(false);
      confForm.render(document.body);
      //confForm.get('msg').setValue(response.responseText);
      confFrom.setVisible(true);

       },
       failure: function(response) {
      mainForm.setVisible(false);
      confForm.render(document.body);
 //     confForm.get('msg').setValue(response.responseText);
      confFrom.setVisible(true);

       },
       params: {
        ac:ac , y:y
       }
    });
                                }
        }]
    });
//json store
 var myJsonStore = new Ext.data.JsonStore({
  reader: new Ext.data.JsonReader({
    fields: ['account','amount','percent','sum'],
    root: 'rows'
   }),
  proxy: new Ext.data.HttpProxy({
    url: 'res.php'
   }),
  autoLoad: true
  });
    // While you can create a basic Panel with layout:'form', practically
    // you should usually use a FormPanel to also get its form functionality
    // since it already creates a FormLayout internally.

 //okno podtverjdenia platezha
    var confForm = new Ext.form.FormPanel({
        title: 'ïîäòâåðäèòå äàííûå',
        bodyStyle: 'padding:15px',
  url: 'none.php',
        width: 400,
        id: 'confForm',
  //po najatiu ok otpravka platezha, cancel = do nothing
  items: [
     {
                xtype: 'displayfield',
    fieldlabel: 'account',
    store: myJsonStore,
    displayField: 'account'
            },
   {
                xtype: 'displayfield',
                name: 'amount',
    fieldlabel: 'amount',
    mode: 'local',
    store: myJsonStore,
    displayField: 'amount'
            },
   {
                xtype: 'displayfield',
                name: 'percent',
    fieldlabel: '1ye gift',
    mode: 'local',
    store: myJsonStore,
    displayField: 'percent'
            },
   {
                xtype: 'displayfield',
                name: 'sum',
    fieldlabel: 'total',
    mode: 'local',
    store: myJsonStore,
    displayField: 'sum'
            }
    ],


        buttons: [{
            text: 'ÎÊ',
            formBind: true,
            handler  : function(){
       var ac = mainForm.get('account').getValue(false);
    var y = mainForm.get('amount').getValue(false);
    //alert(ac+' '+y);
    Ext.Ajax.request({
       url: './res.php',
       method: 'POST',
       success: function(response) {
        confForm.setVisible(false);
        waitForm.render(document.body);
        waitForm.get('res').setValue(response.responseText);
        waitForm.setVisible(true);
       },
       failure: function(response) {
        confForm.setVisible(false);
        waitForm.render(document.body);
        waitForm.get('res').setValue("Error");
        waitForm.setVisible(true);

       },
       params: {
        ac:ac , y:y, final:1
       }
    });

    }
        }, {
            text: 'Îòìåíà',
            formBind: true,
            handler  : function(){
       parent.mainFrame.location = '../main.htm';
                          }
        }],
        layoutConfig: {
            labelSeparator: '~' // superseded by assignment below
        },
        // config options applicable to container when layout='form':
        hideLabels: false,
          // or 'right' or 'top'
        labelSeparator: '>>', // takes precedence over layoutConfig value
        labelWidth: 65,       // defaults to 100
        labelPad: 8           // defaults to 5, must specify labelWidth to be honored
    });

  var waitForm = new Ext.form.FormPanel({
        title: 'processing',
        bodyStyle: 'padding:15px',
        width: 350,
  formId: 'waitform',
        defaultType: 'displayfield',
        defaults: {
            // applied to each contained item
            width: 230,
            msgTarget: 'side',
  },
  items:[
      {
    id: 'res',
                xtype: 'displayfield',
                width: 280,
    layout: 'absolute'
            }
      ],
  buttons: [

       {
      text: 'íà ãëàâíóþ',
      handler: function(){
       parent.mainFrame.location = '../main.htm';
       }
      }
      ]
        });

  mainForm.render(document.body);


});

Herkes söyleyebiliriz nedir bu F * n ext js ve JSON ile sorun?

0 Cevap