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 4026212
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:56:31+00:00 2026-05-20T10:56:31+00:00

Dear All, I’m using dojo.declare to create classes in JavaScript. In one of the

  • 0

Dear All,
I’m using dojo.declare to create classes in JavaScript. In one of the methods, I’ve an AJAX request. In the load method of that request, I need to execute certain methods.These methods are actually methods of the class that was created using dojo.declare. I tried to execute the method using this. But it gave me method not found error. So I used dojo.hitch(this,testMethod) to invoke it. It worked fine. Now the problem is I’ve lot of other methods also inside testMethod() which internally calls other methods of my JavaScript class. It is really a pain to have dojo.hitch() everywhere. Is there any work around for this.

    dojo.declare("TestClass",null,{

    getData:function(url){
    dojo.xhrGet({
      url:url,
      load: function (response){
        dojo.hitch(scope of the current object,testMethod(response))    
      },
      error:function(){

      }
    });
    },
    testMethod:function(response){
    //calls testMethod2. I think I can use dojo.hitch(this,testMethod3) to call it.
    //but I wanted to avoid doing it every time.
    },
    testMethod2:function(){
    //calls testMethod3
    },
    testMethod3:function(){
    //can call other methods.
    }
    });
  • 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-20T10:56:32+00:00Added an answer on May 20, 2026 at 10:56 am

    It seems like that execution scope was lost in this code:

    load: function (response){
            dojo.hitch(this,testMethod(response))   
          },
    

    I made small changes in your code. Now it should work properly.

    dojo.declare("TestClass",null,{
    
            getData:function(url){
            dojo.xhrGet({
              url:url,
              load: dojo.hitch(this,this.testMethod),
              error:function(){
    
              }
            });
            },
            testMethod:function(response){
               this.testMethod2();
            },
            testMethod2:function(){
               this.testMethod3();
            },
            testMethod3:function(){
            //can call other methods.
            }
            });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Dear all, I am building an application on windows phone 7. My application needs
Dear all, I have a data frame which comes directly from a sensor. The
Dear all, this is going to be tough: I have created a game object
Dear All, I used a vector of vector, say vector<vector<int> > no_1_2 to store
Dear Fellow Android Developers! EDIT: Thank you all for your answers. I see from
Dear Stacktoverflow, can you show me an example of how to use a QScrollBar?
Dear g++ hackers, I have the following question. When some data of an object
Given a document written with normal quotes, e.g. Ben said buttons, dear sir. I
Good day dear colleagues, I decided to move some projects from MySQL to MongoDB
dear developer i want make an image from an offscreen view. when i start

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.