1. #1
    Ext User
    Join Date
    Mar 2009
    Posts
    14
    Vote Rating
    0
    king1231986 is on a distinguished road

      0  

    Default Jelp in Air with php

    Jelp in Air with php


    Hi
    I am really struck up in this.. i am new to air.
    This is my code
    Code:
    var PresidentsDataStore;
    var PresidentsColumnModel;
    var PresidentListingEditorGrid;
    var PresidentListingWindow;
    
    Ext.onReady(function() {
    
        Ext.QuickTips.init();
    
        function saveThePresident(oGrid_event) {
            Ext.Ajax.request({
                waitMsg: 'Please wait...',
                url: '1.php',
                params: {
                    task: "UPDATEPRES",
                    IDpresident: oGrid_event.record.data.IDpresident,
                    FirstName: oGrid_event.record.data.FirstName,
                    LastName: oGrid_event.record.data.LastName,
                    PartyName: oGrid_event.record.data.PartyName,
                    TookOffice: oGrid_event.record.data.TookOffice.format('Y-m-d'),
                    LeftOffice: oGrid_event.record.data.LeftOffice.format('Y-m-d'),
                    Income: oGrid_event.record.data.Income
                },
                success: function(response) {
                    var result = eval(response.responseText);
                    switch (result) {
                        case 1:
                            PresidentsDataStore.commitChanges();
                            PresidentsDataStore.reload();
                            break;
                        default:
                            Ext.MessageBox.alert('Uh uh...', 'We couldn\'t save him...');
                            break;
                    }
                },
                failure: function(response) {
                    var result = response.responseText;
                    Ext.MessageBox.alert('error', 'could not connect to the database. retry later');
                }
            });
        }
    
        PresidentsDataStore = new Ext.data.Store({
            id: 'PresidentsDataStore',
            proxy: new Ext.data.HttpProxy({
                url: '1.php',
                method: 'POST'
            }),
            baseParams: { task: "LISTING" }, // this parameter is passed for any HTTP request
            reader: new Ext.data.JsonReader({
                root: 'results',
                totalProperty: 'total',
                id: 'id'
            }, [
            { name: 'IDpresident', type: 'int', mapping: 'IDpresident' },
            { name: 'FirstName', type: 'string', mapping: 'firstname' },
            { name: 'LastName', type: 'string', mapping: 'lastname' },
            { name: 'IDparty', type: 'int', mapping: 'IDparty' },
            { name: 'PartyName', type: 'string', mapping: 'name' },
            { name: 'TookOffice', type: 'date', mapping: 'tookoffice' },
            { name: 'LeftOffice', type: 'date', mapping: 'leftoffice' },
            { name: 'Income', type: 'float', mapping: 'income' }
          ]),
            sortInfo: { field: 'IDpresident', direction: "ASC" }
        });
    
        PresidentsColumnModel = new Ext.grid.ColumnModel(
        [{
            header: '#',
            readOnly: true,
            dataIndex: 'IDpresident',
            width: 40,
            hidden: false
        }, {
            header: 'First Name',
            dataIndex: 'FirstName',
            width: 60,
            editor: new Ext.form.TextField({
                allowBlank: false,
                maxLength: 20,
                maskRe: /([a-zA-Z0-9\s]+)$/
            })
        }, {
            header: 'Last Name',
            dataIndex: 'LastName',
            width: 80,
            editor: new Ext.form.TextField({
                allowBlank: false,
                maxLength: 20,
                maskRe: /([a-zA-Z0-9\s]+)$/
            })
        }, {
            header: 'ID party',
            readOnly: true,
            dataIndex: 'IDparty',
            width: 50,
            hidden: true
        }, {
            header: 'Party',
            dataIndex: 'PartyName',
            width: 150,
            editor: new Ext.form.ComboBox({
                typeAhead: true,
                triggerAction: 'all',
                store: new Ext.data.SimpleStore({
                    fields: ['partyValue', 'partyName'],
                    data: [['1', 'No Party'], ['2', 'Federalist'], ['3', 'Democratic-Republican'], ['4', 'Democratic'], ['5', 'Whig'], ['6', 'Republican']]
                }),
                mode: 'local',
                displayField: 'partyName',
                valueField: 'partyValue',
                lazyRender: true,
                listClass: 'x-combo-list-small'
            })
        }, {
            header: 'Took Office',
            dataIndex: 'TookOffice',
            width: 80,
            renderer: Ext.util.Format.dateRenderer('m/d/Y'),
            editor: new Ext.form.DateField({
                format: 'm/d/Y'
            }),
            hidden: false
        }, {
            header: 'Left Office',
            dataIndex: 'LeftOffice',
            width: 80,
            renderer: Ext.util.Format.dateRenderer('m/d/Y'),
            editor: new Ext.form.DateField({
                format: 'm/d/Y'
            }),
            hidden: false
        }, {
            header: "Income",
            dataIndex: 'Income',
            width: 100,
            renderer: function(v) { return '$ ' + v; },
            editor: new Ext.form.NumberField({
                allowBlank: false,
                allowDecimals: true,
                allowNegative: false,
                blankText: '0',
                maxLength: 11
            })
    }]
        );
            PresidentsColumnModel.defaultSortable = true;
    
            PresidentListingEditorGrid = new Ext.grid.EditorGridPanel({
                id: 'PresidentListingEditorGrid',
                store: PresidentsDataStore,
                cm: PresidentsColumnModel,
                enableColLock: false,
                clicksToEdit: 1,
                selModel: new Ext.grid.RowSelectionModel({ singleSelect: false })
            });
    
            PresidentListingWindow = new Ext.Window({
                id: 'PresidentListingWindow',
                title: 'The Presidents of the USA',
                closable: true,
                width: 700,
                height: 350,
                plain: true,
                layout: 'fit',
                items: PresidentListingEditorGrid
            });
    
            PresidentsDataStore.load();
            PresidentListingWindow.show();
    
            PresidentListingEditorGrid.on('afteredit', saveThePresident);
    
        });
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
            <title>Untitled Document</title>
            <link rel="stylesheet" type="text/css" href="ext-2.0/resources/css/ext-all.css" />
            <link rel="stylesheet" type="text/css" href="ext-air/resources/ext-air.css" />
    
            <script type="text/javascript" src="adobe/AIRAliases.js"></script>
            
            <script type="text/javascript" src="ext-2.0/adapter/ext/ext-base.js"></script>
            <script type="text/javascript" src="ext-2.0/ext-all.js"></script>
            <script type="text/javascript" src="ext-air/ext-air.js"></script>
            <script type="text/javascript" src="1.js"></script>
            <script type="text/javascript" src="js/ext-config.js"></script>
        </head>
        <body>
        </body>
    </html>
    
    But i dont get any data in the grid what seems to be the problem.. If i run this code normally in IE i get the data in the grid... Is there anything i have to do in Aptana to access XMLhttprequest config

  2. #2
    Ext User
    Join Date
    Jan 2009
    Posts
    44
    Vote Rating
    0
    wmazza is on a distinguished road

      0  

    Default


    first off, try adding AIRIntrospector.js to your header, after your adobe/AIRAliases.js call. Introspector is simlar (but not as good! :P) as firebug and is activated by pressing F12 when you are running your application. Introspector will allow you to check what the XHR request is, and what the server returned. If your grid is not populating, it could be because the server is not sending any or malformed JSON data

    however, i think the issue may be this line
    Code:
    var result = eval(response.responseText);
    try changing it to
    Code:
    var result = eval('('+response.responseText+')');
    but then again, it all depends on what your server is returning. =)

  3. #3
    Ext User
    Join Date
    Mar 2009
    Posts
    14
    Vote Rating
    0
    king1231986 is on a distinguished road

      0  

    Default


    I added AIRIntrospector.js and while running i pressed F12 i get this error

    about:blank:6265 HTML ERROR: Unmatched </head> encountered. Ignoring tag.

    about:blank:6267 HTML ERROR: Extra <body> encountered. Migrating attributes back to the original <body> element and ignoring the tag.

  4. #4
    Ext User
    Join Date
    Mar 2009
    Posts
    14
    Vote Rating
    0
    king1231986 is on a distinguished road

      0  

    Default


    [quote=king1231986;315648]I added AIRIntrospector.js and while running i pressed F12
    I got no reponse from the server. I could find there is no post from air.

    I ran my application in firefox and not in Air. I get the response.

    please help me. I am not able to move forward.

    I am using WAMP server 2.0g

  5. #5
    Ext User
    Join Date
    Jan 2009
    Posts
    44
    Vote Rating
    0
    wmazza is on a distinguished road

      0  

    Default


    Hmm.... possible its returning an HTML file, which is why its closing/opening your <head> and <body> tags?


    for your sucess function, change it to

    Code:
    function (response) {
    alert(response.responseText);
    }
    let me know what returns

  6. #6
    Ext User
    Join Date
    Jan 2009
    Posts
    44
    Vote Rating
    0
    wmazza is on a distinguished road

      0  

    Default


    oh you know, i didnt see your 3rd post there above mine till just now :P

    did you change the URL from 1.php to the full url (www.example.com/1.php) ?

  7. #7
    Ext User
    Join Date
    Mar 2009
    Posts
    14
    Vote Rating
    0
    king1231986 is on a distinguished road

      0  

    Default


    hi i gave the full link no good luck

    and i also tried this but this also doest seems to work...

    Code:
    <html>
        <head>
            <title>Application Sandbox sample</title>
            <link href="sample.css" rel="stylesheet" type="text/css"/>
            
            <link rel="stylesheet" type="text/css" href="lib/ext/resources/css/ext-all.css" />
             <link rel="stylesheet" type="text/css" href="lib/air/resources/ext-air.css" />
            
            <script type="text/javascript" src="lib/air/AIRAliases.js"></script>
            <script type="text/javascript" src="lib/air/AIRIntrospector.js"></script>
            
             <script type="text/javascript" src="lib/ext/adapter/ext/ext-base.js"></script>
            <script type="text/javascript" src="lib/ext/ext-all.js"></script>
            <script type="text/javascript" src="lib/ext/air/ext-air.js"></script>
            <script type="text/javascript">
    
                
                // loads the content of a remote URL
                function doRequest() {
                    alert();
                   var req = new XMLHttpRequest();
                   req.onreadystatechange = function() { 
                        if (req.readyState == 4) {
                            var str = req.responseText;
                            if (str.length > 400) {
                                str = str.substring(0, 399);
                                str += "..";
                            }
                            alert('readystate: ' + req.readyState + '\n' +
                                'status/statusText: ' + req.status + '/' + 
                                 req.statusText + '\n' +
                                'responseText (400 chars): '  + "\n\n" + str);
                        }
                    };
                    req.open('GET', "http://localhost/madonna/1.php", true);
                    req.send(null);                
                }
                
                function openInBrowser(url) {
                    air.navigateToURL( new air.URLRequest(url)); 
                }
                
            </script>
        </head>
    
        <body>
            <h3>Application Sandbox Content</h3>
            
            <ul>
                <li>Has access to AIR APIs:
                <input type="button" id="btn1"
    onclick="doRequest()"
    value="Log" />
                 
            
        </body>
    </html>

  8. #8
    Ext User
    Join Date
    Mar 2009
    Posts
    14
    Vote Rating
    0
    king1231986 is on a distinguished road

      0  

    Default


    A request is given but no response it no data arrives

    this is wat i get

    GET http://localhost/madonna/1.php
    -
    readyState 1
    async true
    responseText
    -
    1
    EOF
    responseXML


    you see there is no response...

  9. #9
    Ext User
    Join Date
    Jan 2009
    Posts
    44
    Vote Rating
    0
    wmazza is on a distinguished road

      0  

    Default


    all your JS code looks fine and the fact that you received a response, albeit blank, means your AIR app is making a successful connection to your server (localhost). At this point, I have to say it is your PHP script: does it require parameters to be sent in order for it to return data? Does it matter if its a GET or POST request?

    (edited for typos)

  10. #10
    Ext User
    Join Date
    Mar 2009
    Posts
    14
    Vote Rating
    0
    king1231986 is on a distinguished road

      0  

    Default


    no it does not matter whether it is get or post for me. I gave try regarding a simple try either like this
    Code:
    echo '{success:true}';
    I would been happier if i get this response to but no.

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi