1. #1
    Sencha User
    Join Date
    Aug 2010
    Location
    Europa
    Posts
    216
    Vote Rating
    1
    kortovos is on a distinguished road

      0  

    Question Add parameters to Ajax proxy

    Add parameters to Ajax proxy


    How do you add parameters to an Ajax store?

    I am bypassing the cross domain policy by using a php proxy on my server. I am trying to send a few needed parameters to the php page and I expect the response to be xml.

    But how do I send certain parameters to the php page on the server?

    PHP Code:
      var orderStore = new Ext.data.Store({
                
    model'order',
                
    urlvarxml,
                
    proxy: {
                    
    type:'ajax',
                    
    id'data',
                    
    url'proxytest.php',
                    
    method"POST",
                    
    params:{action'askorderlist',
                         
    question'uborderlist',
                         
    value'2010-08-01',
                         
    user'username',
                         
    password'password'
                     
    },
                    
    reader: {
                        
    type'xml',
                        
    record'order'
                    
    }
                },
        
    autoloadtrue,
        }); 

  2. #2
    Sencha User
    Join Date
    Aug 2010
    Posts
    303
    Vote Rating
    3
    steve1964 is on a distinguished road

      1  

    Default


    Just append the parameter to the url:

    Code:
    var orderStore = new Ext.data.Store({
                model: 'order',
                url: varxml,
                proxy: {
                    type:'ajax',
                    id: 'data',
                    url: 'proxytest.php?username=dummy&age=' + somevar,
                    method: "POST",
                    params:{action: 'askorderlist',
                         question: 'uborderlist',
                         value: '2010-08-01',
                         user: 'username',
                         password: 'password'
                     },
                    reader: {
                        type: 'xml',
                        record: 'order'
                    }
                },
        autoload: true,
        });

  3. #3
    Sencha User
    Join Date
    Aug 2010
    Location
    Europa
    Posts
    216
    Vote Rating
    1
    kortovos is on a distinguished road

      1  

    Default


    Isn't that a 'GET'? And if so, isn't there a limit to the number of characters you can append to the url?

    What if I want to use a 'POST'?

  4. #4
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,823
    Vote Rating
    608
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      1  

    Default


    Code:
    Ext.setup({
        onReady: function(){
            Ext.regModel('Foo', {
                fields: ['a']    
            });
            
            new Ext.data.Store({
                autoLoad: true,
                model: 'Foo',
                proxy: {
                    url: 'data.asp',
                    type: 'ajax',
                    extraParams: {
                        foo: 'bar'
                    }
                }
            });
        }
    });
    By default all read operations will be a get. You can override it for a single instance by using:

    Code:
    // create store
    myStore.proxy.actionMethods.read = 'POST';
    myStore.load();
    Or globally:
    Code:
    Ext.apply(Ext.data.AjaxProxy.prototype.actionMethods, {
         read: 'POST'
    });
    // create store
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  5. #5
    Sencha User
    Join Date
    Aug 2010
    Location
    Europa
    Posts
    216
    Vote Rating
    1
    kortovos is on a distinguished road

      0  

    Default


    Thanks Evant for your quick response. In your example the extraParams you pass to the proxy also are present in the model, is this a necessity?

    I am still getting errors. Is there a 'success' and 'failure' parameter for stores or readers, like with an Ext.Ajax.request?
    PHP Code:
    XHR finished loading"http://localhost/proxytest.php?_dc=1285569086510".ext-touch-debug.js:7732
    Uncaught 
    #<an Object>
    getResponseData ext-touch-debug.js:7732
    readext
    -touch-debug.js:7235
    (anonymous function)ext-touch-debug.js:6620
    onCompleteext
    -touch-debug.js:14577
    onStateChangeext
    -touch-debug.js:14524
    (anonymous function)ext-touch-debug.js:2618 

  6. #6
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,823
    Vote Rating
    608
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    No, I just happened to use the same name for the model and the property, they are in no way related.

    As for the other one, it sounds like you're sending back malformed data.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  7. #7
    Sencha User
    Join Date
    Aug 2010
    Location
    Europa
    Posts
    216
    Vote Rating
    1
    kortovos is on a distinguished road

      0  

    Default


    The response should be something like : <?xml version="1.0" encoding="UTF-8"?><orderlist><order><orderid>2005048</orderid></order><order><orderid>3000359</orderid></order><order><orderid>2007062</orderid></order><order><orderid>2007118</orderid></order><order><orderid>3000362</orderid></order><order><orderid>2007134</orderid></order><order><orderid>2007135</orderid></order><order><orderid>2007142</orderid></order><order><orderid>3000367</orderid></order><order><orderid>2007178</orderid></order></orderlist>

    Could it be the header (<?xml version="1.0" encoding="UTF-8"?>) that is causing the problem?
    With Chrome dev tools, when I click on "http://localhost/proxytest.php?_dc=1285569086510", it displays the correct output.

  8. #8
    Sencha User
    Join Date
    Aug 2010
    Location
    Europa
    Posts
    216
    Vote Rating
    1
    kortovos is on a distinguished road

      0  

    Default


    And my model is
    PHP Code:
    Ext.regModel('order', {
        
    fields : [ {
            
    name 'orderid',
            
    type 'integer'
        
    }]
    }); 
    Anyone an idea what I am doing wrong?

  9. #9
    Sencha User
    Join Date
    Aug 2010
    Location
    Europa
    Posts
    216
    Vote Rating
    1
    kortovos is on a distinguished road

      0  

    Default


    Oke, I made sure that the server returns text/xml, by adding 'header("Content-Type: text/xml");' to the php document. So now I don't get any errors, but the store still doesn't get filled.

  10. #10
    Sencha User
    Join Date
    Aug 2010
    Posts
    303
    Vote Rating
    3
    steve1964 is on a distinguished road

      0  

    Default


    How you check if the store is filled?

Similar Threads

  1. Ajax.request VS Store proxy
    By merry andrew in forum Sencha Touch 1.x: Discussion
    Replies: 1
    Last Post: 23 Aug 2010, 4:09 PM
  2. Ajax Proxy/Json Store
    By eldiego34 in forum Sencha Touch 1.x: Discussion
    Replies: 2
    Last Post: 19 Aug 2010, 4:59 AM
  3. Replies: 2
    Last Post: 29 Jun 2010, 2:46 PM
  4. Problem with proxy ajax call
    By mysticav in forum Ext 2.x: Help & Discussion
    Replies: 5
    Last Post: 4 Dec 2008, 12:10 PM
  5. is data proxy is the same as ajax?
    By ratno in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 24 Nov 2008, 8:35 AM

Thread Participants: 4

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