1. #1
    Sencha User
    Join Date
    Sep 2012
    Posts
    4
    Vote Rating
    0
    hatoh is on a distinguished road

      0  

    Default Unanswered: Unable to run javascript using Ext.Ajax?

    Unanswered: Unable to run javascript using Ext.Ajax?


    Hi,

    I am using htmlPanel.js which was discussed in the Forum here to display local html content. I am able to load the html content with normal html tag, but not the javascript.

    Below is the htmlPanel.js I used:
    Code:
    Ext.define('HTMLPanel', {
        extend: 'Ext.Panel',
    
    
    // We are using Ext.Ajax, so we should require it
        requires: ['Ext.Ajax'],
        config: {
            listeners: {
                activate: 'onActivate'
            },
    
    
    // Create a new configuration called `url` so we can specify the URL
            url: null        
        },
    
    
        onActivate: function(me, container) {
            Ext.Ajax.request({
    // we should use the getter for our new `url` config
                url:    'htmlTest.html',//this.getUrl(),
                method: "GET",
                success: function(response, request) {
    // We should use the setter for the HTML config for this
    //Ext.Msg.alert('Alert', 'Success!!!', Ext.emptyFn);    
                    me.setHtml(response.responseText);                
                },
                failure: function(response, request) {
    //Ext.Msg.alert('Alert', 'Failure!!!', Ext.emptyFn);    
                    me.setHtml("failed -- response: " + response.responseText);
                }
            });
        }
    });
    Below is my htmlTest.html:

    Code:
    <!DOCTYPE html>
    <html>
        <body>
    
            <canvas id="myCanvas">Your browser does not support the HTML5 canvas tag.</canvas>
    
            <script type="text/javascript" charset="utf-8">
                var c=document.getElementById('myCanvas');
                var ctx=c.getContext('2d');
                ctx.fillStyle='#FF0000';
                ctx.fillRect(0,0,640,1280);
            </script>
    
            <h1>This is some text in a paragraph.</h1>
    
        </body>
    </html>
    

    And below is my index.js
    Code:
    Ext.application({
        name: 'SampleLoad',
        launch: function () {
    
            Ext.Viewport.add({
                            url:     'htmlTest.html',
                xclass: "HTMLPanel",
    
    
            });
        }
    });

    I am able to see the text "Some text is here.", but not the canvas that I tried to create using javascript.

    Is there any config that needs to be specified? Or any other cause?

    Thanks.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,397
    Answers
    3549
    Vote Rating
    849
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    That can be highly dangerous to do
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

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

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

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

  3. #3
    Sencha User
    Join Date
    Sep 2012
    Posts
    4
    Vote Rating
    0
    hatoh is on a distinguished road

      0  

    Default


    Meaning Sencha-Touch does not support script tag?

Thread Participants: 1

Tags for this Thread