1. #1
    Sencha User
    Join Date
    Mar 2014
    Posts
    98
    Answers
    5
    Vote Rating
    -4
    franva is infamous around these parts franva is infamous around these parts

      1  

    Default Answered: code works in chrome on my PC but doesn't work in my devices

    Answered: code works in chrome on my PC but doesn't work in my devices


    I am using Sencha Touch and trying to get data from a remote server
    Here is my store

    Code:
    Ext.define('webTrak.store.NoiseStore', {
            extend: 'Ext.data.Store',
            requires: ['webTrak.model.noiseChunk', 'Ext.data.reader.Xml'],
            config:{
                autoLoad: true,
                storeId: 'NoiseStore',
                model: 'webTrak.model.noiseChunk',
                proxy: {
                    type: 'ajax',
                    //url: "https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20xml%20where%20url%3D'http%3A%2F%2Fwebtrak.bksv.com%2Fmel%2Fdata%2F46610526'&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=",
                    url: 'http://webtrak.bksv.com/mel/data/46611635',
                    //url:'app/store/now.xml',
                    reader: {
                        type: 'xml',
                        //rootProperty: 'results',
                        record: 'data'
                    }
                }
            }
          
        });

    and my controller


    Code:
    noiseStore.load({
                    callback: function (records, operation, success) {
                        myop = records;
        
                        if (!success) {
                            Ext.Msg.alert('Failed!', records[0]);
                        }
                        else
                        {
                            Ext.Msg.alert('Success!', $(records[0].raw).html());
                        }
        
                        var lines = $(records[0].raw).html().split('\n');
                        //var lines = records[0].raw.innerHTML.split('\n');
                        Ext.Msg.alert('number of lines', lines);
        
        
                        Ext.Object.each(lines, function (key, value, myself) {
                            //window.setInterval(function () { }, 1000);
                            Ext.Function.defer(function () {
                                var fields = value.split(',');
                                var isNoise = fields[0];
                                if (isNoise === 'noise') {
                                    console.log('noise = ' + fields[5]);
                                    Ext.Msg.alert('noise', fields[5]);
        
                                    var locid = fields[3];
                                    var noisevalue = fields[5];
        
                                    var overlayTmp = new Ext.Template('<div class="overlay">{noiseValue}</div>', { compiled: true });
                                    overlayTmp.compile();
                                    var overlayHtml = overlayTmp.apply({ noiseValue: noisevalue });
        
                                    var tempOverLay = sensorSet[locid];
                                    tempOverLay.onRemove();
        
                                    sensorSet[locid].setValues({
                                        content: overlayHtml
                                    });
        
                                    sensorSet[locid].onAdd();
                                    sensorSet[locid].draw();
                                }
                                else {
                                    console.log('radar = ' + fields[10]);
                                }
                            }, 2000);
                            //window.setInterval(function () {
                              
                            //}, 1000);
        
                          
                        });
        
                    }
                });

    And this is the data source : http://webtrak.bksv.com/mel/data/46611635

    Please help me make it work in devices~~~ thank you

  2. Quote Originally Posted by fmoseley View Post
    What os is the device running? Are you testing as a web app or a packaged application? Where is it failing? What debugging have you done so far?
    I tested on 2 devices: Android and WP8, it's a mobile application not a web app.
    I tried to use Weinre but it doesn't help much as the console doesn't display errors or warnings, so I manually inserted many alert/log to see at which step it stops and found the issue.

    The problem is caused by using htmlElement.innerHTML.

    It is not a best practice to use the innerHTML when developing mobile apps, so I used XMLSerializer to de-serialize the xml content and successed.

    But I am not sure it's the best way to do it. So it's wonderful if you could let me know the best way to get the xml content from a http request.

    Thank you.

  3. #2
    Sencha - Support Team
    Join Date
    Oct 2011
    Posts
    3,955
    Answers
    330
    Vote Rating
    132
    fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all

      0  

    Default


    What os is the device running? Are you testing as a web app or a packaged application? Where is it failing? What debugging have you done so far?
    Get more personalized support via a support subscription.

    Want to learn Sencha Touch 2? Check out
    Sencha training
    Sencha Touch in Action

    Need more help with your app? Hire Sencha Services services@sencha.com

    When posting code, please use BBCode's CODE tags.

    Need to include a test case use:
    The official Sencha Fiddle

  4. #3
    Sencha User
    Join Date
    Mar 2014
    Posts
    98
    Answers
    5
    Vote Rating
    -4
    franva is infamous around these parts franva is infamous around these parts

      0  

    Default Reply to you

    Reply to you


    Quote Originally Posted by fmoseley View Post
    What os is the device running? Are you testing as a web app or a packaged application? Where is it failing? What debugging have you done so far?
    I tested on 2 devices: Android and WP8, it's a mobile application not a web app.
    I tried to use Weinre but it doesn't help much as the console doesn't display errors or warnings, so I manually inserted many alert/log to see at which step it stops and found the issue.

    The problem is caused by using htmlElement.innerHTML.

    It is not a best practice to use the innerHTML when developing mobile apps, so I used XMLSerializer to de-serialize the xml content and successed.

    But I am not sure it's the best way to do it. So it's wonderful if you could let me know the best way to get the xml content from a http request.

    Thank you.

  5. #4
    Sencha - Support Team
    Join Date
    Oct 2011
    Posts
    3,955
    Answers
    330
    Vote Rating
    132
    fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all fmoseley is a name known to all

      0  

    Default


    Try doing a Ext.Ajax.request and parse the the responseText.
    http://docs.sencha.com/touch/2.3.1/#!/api/Ext.Ajax
    Get more personalized support via a support subscription.

    Want to learn Sencha Touch 2? Check out
    Sencha training
    Sencha Touch in Action

    Need more help with your app? Hire Sencha Services services@sencha.com

    When posting code, please use BBCode's CODE tags.

    Need to include a test case use:
    The official Sencha Fiddle

  6. #5
    Sencha User
    Join Date
    Mar 2014
    Posts
    98
    Answers
    5
    Vote Rating
    -4
    franva is infamous around these parts franva is infamous around these parts

      0  

    Default Reply to you

    Reply to you


    Quote Originally Posted by fmoseley View Post
    Try doing a Ext.Ajax.request and parse the the responseText.
    http://docs.sencha.com/touch/2.3.1/#!/api/Ext.Ajax
    Thank you fmoseley

  7. #6
    Sencha User
    Join Date
    Mar 2014
    Posts
    98
    Answers
    5
    Vote Rating
    -4
    franva is infamous around these parts franva is infamous around these parts

      0  

    Default Reply to you

    Reply to you


    Btw, what are the advantages of using Ext.Ajax.request over jQuery's Ajax call?

Thread Participants: 1

Tags for this Thread