Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6885885
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:41:26+00:00 2026-05-27T05:41:26+00:00

I have an ExtJs application which loads quite a good number of javascript files.

  • 0

I have an ExtJs application which loads quite a good number of javascript files. This leads to alot of overhead and hence we are now loading the javascript files using Ajax.

Thus, when user clicks a button, then the javascript file carrying the function associated with the button is loaded using Ajax following way:

Ext.Ajax.request({
    url:'filePath',
    success:function(response){
        eval(response.responseText);
        functionAssociatedWithButton();//Calling here the function associated with button
    },
    failure:function(){
        return;
    }
});

functionAssociatedWithButton();//Calling here the same function throws an error of function being undefined

The issue is that this function – functionAssociatedWithButton() – which is present in the JS file loaded using Ajax, is available and gets executed only in the success function of Ajax request.

But if we try accessing this function in any other section of the script then JS engine throws an error – functionAssociatedWithButton() is not defined.

How could such a function, which is present in the JS file loaded using Ajax, be made available in the rest of the script?

I tried using the 4th option suggested here – but this too didn’t resolve the issue.

Could anyone please throw some light on this.

Thanks in advance.

PS: The complete script is written inside onReady function of ExtJS. Also, considering the possibility that Ajax might not have loaded by the time function is called somewhere else, I have tried this case by calling the function after Ajax has finished loading (using isLoading() and setTimeOut()) but even when the Ajax has finished loading, the function gets to be recognized only in the success function of Ajax and not recognized anywhere else in the script.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:41:27+00:00Added an answer on May 27, 2026 at 5:41 am

    This to do with the scope of the function which you have created. The function will only be available within the success function; you effectively end up with the following scenario:

    function foo() {
        function bar() {
            window.alert("hello");
        }
    }
    
    console.log(typeof foo); // function
    console.log(typeof bar); // undefined
    

    You could have a global namespace object which you add the function to, something like:

    var test = {};
    
    function foo() {
        test.bar = function () {
            window.alert("hello");
        }
    }
    
    console.log(typeof foo); // function
    foo();
    console.log(typeof test.bar); // function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JavaScript application which opens an ExtJS Window, containing an ExtJS TabPanel,
I have an ExtJS application which is invoked with some query string parameters. I
I am using this article of architecture http://blog.extjs.eu/know-how/writing-a-big-application-in-ext/ I have this one function where
I am using this article of architecture http://blog.extjs.eu/know-how/writing-a-big-application-in-ext/ in my code: I have this
I have a ExtJs application. When user needs to view PDF report generated on
I have the following extJs window which has two tabs in it. One of
We have RoR application and we are planning to make js interface(extjs or closure)
I have an application using OpenLayers , Extjs and GeoExt . My application runs
I have implemented a Web - Application which features a GridPanel which can be
I am using a extjs field container for my application where I have details,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.