1. #1
    Sencha User
    Join Date
    Aug 2012
    Posts
    4
    Answers
    1
    Vote Rating
    0
    AntaresDaha is on a distinguished road

      0  

    Default Answered: JSONP request doesn't return data, but same? request works fine in store.

    Answered: JSONP request doesn't return data, but same? request works fine in store.


    I am pretty new to the concept of JSON/JSONP so i guess I am just missing something very obvious.
    I try to figure out how to invoke a JSONP request to a .php script, which in return should provid me with some simple JSON data.
    This is my .php script:
    PHP Code:
    <?php
    $callback 
    $_REQUEST['callback'];
    $data 
    '[
        {     "id": 1, 
            "name": "Orankesee", 
            "additional": "abc", 
            "url": "www.url.de", 
            "creator": "Beide" },
        {     "id": 2, 
            "name": "Tanzen gehen", 
            "additional": "abc", 
            "url": "www.url.de", 
            "creator": "Valeska" }, 
    ]'
    ;

    if (
    $callback) {
        
    header('Content-Type: text/javascript');
        echo 
    $callback '(' $data ');';
    } else {
        
    header('Content-Type: application/x-json');
        echo 
    $data;
    }
    ?>
    as you can see, pretty straight forward.

    Now if I attach a jsonp store proxy that calls this script, everything seems to work fine, the JSON data gets loaded into my store, which is then displayed correctly in a view.
    Here is the code of that proxy:
    Code:
    proxy: {
                type: 'jsonp',
                url: 'http://mydomain.com/hosted/test.php',
    
                reader: {
                    type: 'json'
                }
            }
    Now if i try to invoke that .php-Skript on my own, I try something like this:
    Code:
    jsonpTest: function(){
        console.log('jsonpTest started!');
        Ext.util.JSONP.request({
            url: 'http://mydomain.com/hosted/test.php',
            callbackKey: 'callback',
            callback: function (jsonData) {
                console.log('jsonpTest raw:', jsonData);
                console.log('jsonpTest parsed:', Ext.decode(jsonData));
            }
        });
    }
    This function seems to legitimately call the .php script, but if i debug the returned data (jsonData) all it seems to contain is the value 'true'.
    Am I missing a second parameter on the callback function, one that contains the response, while I am just getting returned that the request itself worked or something?

  2. Code:
    callback:function (success, result, errorType, request)
    so your 'jsonData' always be a boolean value.

  3. #2
    Sencha User
    Join Date
    Apr 2010
    Location
    China
    Posts
    227
    Answers
    64
    Vote Rating
    20
    haduki will become famous soon enough haduki will become famous soon enough

      0  

    Default


    Code:
    callback:function (success, result, errorType, request)
    so your 'jsonData' always be a boolean value.

  4. #3
    Sencha User
    Join Date
    Aug 2012
    Posts
    4
    Answers
    1
    Vote Rating
    0
    AntaresDaha is on a distinguished road

      0  

    Default


    I actually tried to look up the (possible) params in the Sencha Docs, here:
    http://docs.sencha.com/touch/2-0/#!/...method-request
    but there I couldn't find the functions signature. -.-
    Where did you look up the functions signature?? I guess I could really use an IDE with auto-completition/suggestions for such scenarios, it saves so much time, but all plugins/IDEs i tried out so far were far from clever/helpful or slowed down the IDE itself tremendously (e.g. the sencha eclipse plugin ).

Thread Participants: 1

Tags for this Thread

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..."