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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:05:29+00:00 2026-06-07T08:05:29+00:00

We are using jQuery in our application for making AJAX calls. How do I

  • 0

We are using jQuery in our application for making AJAX calls. How do I inovke a method in a particular context using jQuery? In dojo we used to do it using dojo.hitch().
Is there something similar in jQuery? Below is the sample code that we are using. I need to execute the success handler in the context of SampleMethod. The below code should
give me exception since resultSetHandler is not available in the window context. Could you please let me know.

We are using jQuery version 1.3.2

function SampleMethod(){
    this.invokeProcedure=function(procedurePath){
        $.ajax({
                type: "GET",
                url: procedurePath,
                dataType: "json",
                success: resultSetHandler,
                error: errorHandler
            });
    }

    this.resultSetHandler=function(args){
        //Handle the result
    }

    this.errorHandler=function(args){
        //Handle the result
    }

}

var sampleObj=new SampleMethod();
sampleObj.invokeProcedure('url');
  • 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-06-07T08:05:33+00:00Added an answer on June 7, 2026 at 8:05 am

    Just preserve this and wrap them in functions:

    this.invokeProcedure=function(procedurePath){
            var savedThis = this;
            $.ajax({
                    type: "GET",
                    url: procedurePath,
                    dataType: "json",
                    success: function() { savedThis.resultSetHandler(); },
                    error: function() { savedThis.errorHandler(); }
                });
        }
    

    (Probably should pass the “success” function argument forward to “resultSetHandler” too.)


    edit — the above will handle this sort of issue in the general case, but @Blaster correctly points out in a comment that the jQuery $.ajax mechanism provides a simpler solution. A context property can be set in the parameter object you pass in, and the value will be used as the context for the callbacks. That is, adding:

    context: this,
    

    to the $.ajax parameter object would make things work as you originally wrote it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have started using ajax/jQuery in our websites / application. There are many plugins
We are using the jQuery UI slider widget in our web application and we
We are currently using the struts2-jquery plugin in our web-application. The plugin works great
we are using a jquery tree in our asp.net mvc application and have forms
We are using jQuery in our project. We have numerous custom javascript files in
I'm building a simple search table (eventually using jquery Datatables) for our knowledgebase. I'm
I am using jquery Tiny Carousel for sliding images but our client asks for
I'm using the JQuery scrollTo plugin on our one-page site to vertically scroll between
I'm using this jquery plugin ajaxFileupload in our project. My design is I have
We're using jQuery.ajax() methods to request server data on a number of pages on

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.