1. #1
    Sencha User pcr's Avatar
    Join Date
    Jun 2009
    Posts
    183
    Vote Rating
    2
    pcr is on a distinguished road

      0  

    Default I'm confused about GET and POST in Sencha-touch

    I'm confused about GET and POST in Sencha-touch


    I have a lot of PHP serverscripts that produce JSON from a DB to fill a store. These scripts looks for POST and GET parameters. If a POST parameter is available the script send normal JSON. If only GET parameter is received the script sends callback(.....) javascript. Because in ExtJS HttpProxy is default send with type: 'POST' and HttpScriptTagProxy requests are send with default type: 'GET'.

    I expected Sencha-touch behave like ExtJS. No matter what I try to make request to get storedata Sencha-touch always send a GET request with URL-params. Another issue is that Sencha-touch expects a JSON message back and not a callback javascript.

    As a workaround I sent an extra param mobile: true in requests. My PHP scripts now looks for this ??GET param mobile and act like a request width send with POST and send back a JSON message.

    Is it possible to make requests that use type: POST???

  2. #2
    Sencha - Services Team AndreaCammarata's Avatar
    Join Date
    Jun 2009
    Posts
    1,394
    Vote Rating
    22
    AndreaCammarata has a spectacular aura about AndreaCammarata has a spectacular aura about

      0  

    Default


    Hi, sure you can make POST requests.
    Try to write your request like this:

    PHP Code:
    Ext.Ajax.request({
        
    url'your_url'
        
    method'post',
        
    params: {
            
    my_param'my_value'
        
    },
        
    success: function(responseopts) {
                        
               
    //Do what you want
         
    }
    }) 
    Hope this helps.
    Sencha Inc
    Andrea Cammarata, Solutions Engineer
    CEO at SIMACS

    @AndreaCammarata
    www.andreacammarata.com
    github: https://github.com/AndreaCammarata

    TUX components bundle for Sencha Touch 2.x.x
    http://www.tux-components.com/


  3. #3
    Sencha User pcr's Avatar
    Join Date
    Jun 2009
    Posts
    183
    Vote Rating
    2
    pcr is on a distinguished road

      0  

    Default


    Hi Andrea,

    I know. I used that always in ExtJS. Works perfect. But if you try to define a proxy like following code, Sencha-touch ignores the parameter and always sends a GET Request with values added in the URL.

    Code:
    	var servincidentStore = new Ext.data.Store({
    		model: 'Incident',
    		storeId: 'incident',
    		proxy: {
    			type: 'ajax',
    			url: '/generator-grid/BackendGrid/incidentGridBackend.php',
    			method: 'POST',
    			extraParams: {
    				mobile: true,
    				start: 0,
    				limit: 9999,
    				userProfielId: profielid,
    				task: 'LISTING',
    				xvelden: ', incident.PersoonId ',
    				sort: 'incident.Incident',
    				dir: 'ASC'
    			},
    			reader: {
    				type: 'json',
    				root: 'results'
    			}
    		}
    	});
    Here is a copy of the request send by code above:

    Code:
    Verzoek-URL:http://localhost/generator-grid/BackendGrid/incidentGridBackend.php?_dc=1295089977116&mobile=true&start=0&limit=25&userProfielId=791&task=LISTING&xvelden=%2C%20incident.PersoonId%20&sort=incident.Incident&dir=ASC
    Verzoekmethode:GET
    Statuscode:200 OK
    Vraagkopteksten

  4. #4
    Sencha - Services Team AndreaCammarata's Avatar
    Join Date
    Jun 2009
    Posts
    1,394
    Vote Rating
    22
    AndreaCammarata has a spectacular aura about AndreaCammarata has a spectacular aura about

      0  

    Default


    Hi,
    Sencha Touch it's a little bit different from Ext.
    If you have to get data from a Store using Post, you have to set the actionMethods config as follow instead of method.

    PHP Code:
    var servincidentStore = new Ext.data.Store({
        
    model'Incident',
        
    storeId'incident',
        
    proxy: {
            
    type'ajax',
            
    url'/generator-grid/BackendGrid/incidentGridBackend.php',
            
    actionMethods: {
             
    read'POST'
            
    },
            
    extraParams: {
                
    mobiletrue,
                
    start0,
                
    limit9999,
                
    userProfielIdprofielid,
                
    task'LISTING',
                
    xvelden', incident.PersoonId ',
                
    sort'incident.Incident',
                
    dir'ASC'
           
    },
           
    reader: {
              
    type'json',
              
    root'results'
           
    }
        }
    }); 
    Hope this helps.
    Sencha Inc
    Andrea Cammarata, Solutions Engineer
    CEO at SIMACS

    @AndreaCammarata
    www.andreacammarata.com
    github: https://github.com/AndreaCammarata

    TUX components bundle for Sencha Touch 2.x.x
    http://www.tux-components.com/


  5. #5
    Sencha User
    Join Date
    May 2011
    Location
    Lahore, Pakistan
    Posts
    3
    Vote Rating
    0
    tahir_rauf is on a distinguished road

      0  

    Default


    We're trying the same way but getting the following error, Stuck in this , using Sencha touch

    If you call this using Chrome's REST Console plugin it returns correct response, but May be in case of POST request from STORE it adds some header?

    Can anybody please help here...

    Following is the code

    -----------------------CODE-----------------

    var ProductListStore = new Ext.data.Store({
    model: 'ProductListRoot',
    proxy: {
    type: 'ajax',
    actionMethods: {
    read: 'POST'
    },
    url: urlIdentifier + instanceId + implementationId + productListSearchURL,
    reader:{
    type: 'json',
    root: 'contents'
    }

    },
    autoLoad:true
    });
    ---------------------------------------------------




    and Following is the error

    Following is the error return if we inspect in the browser's console.

    ----------------------------------ERROR---------------------------

    <html><head><title>Apache Tomcat\/5.5.23 - Error report<\/title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--><\/style> <\/head><body><h1>HTTP Status 404 - Invalid numeric value: Missing integer part (next char '-' (code 45))\n at [Source: ------------------------------be6f1d32f73c\r\nContent-Disposition: form-data; name=&quot;limit&quot;\r\n\r\n25\r\n------------------------------be6f1d32f73c--\r\n; line: 1, column: 3]<\/h1><HR size=\"1\" noshade=\"noshade\"><p><b>type<\/b> Status report<\/p><p><b>message<\/b> <u>Invalid numeric value: Missing integer part (next char '-' (code 45))\n at [Source: ------------------------------be6f1d32f73c\r\nContent-Disposition: form-data; name=&quot;limit&quot;\r\n\r\n25\r\n------------------------------be6f1d32f73c--\r\n; line: 1, column: 3]<\/u><\/p><p><b>description<\/b> <u>The requested resource (Invalid numeric value: Missing integer part (next char '-' (code 45))\n at [Source: ------------------------------be6f1d32f73c\r\nContent-Disposition: form-data; name=&quot;limit&quot;\r\n\r\n25\r\n------------------------------be6f1d32f73c--\r\n; line: 1, column: 3]) is not available.<\/u><\/p><HR size=\"1\" noshade=\"noshade\"><h3>Apache Tomcat\/5.5.23<\/h3><\/body><\/html>
    -----------------------------
    -- Tahir Rauf

Similar Threads

  1. Replies: 10
    Last Post: 20 Jan 2012, 10:10 AM
  2. Sencha Touch on iPhone v1 / iPod touch v1 ?
    By palnap in forum Sencha Touch 1.x: Discussion
    Replies: 4
    Last Post: 28 Oct 2010, 5:30 PM
  3. you should update the post title to "Sencha Touch Releases & Notes (0.98)"
    By sandor in forum Sencha Touch 1.x: Discussion
    Replies: 0
    Last Post: 28 Oct 2010, 11:25 AM
  4. Replies: 2
    Last Post: 9 Sep 2010, 10:24 AM

Thread Participants: 2

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar