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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:25:37+00:00 2026-05-12T07:25:37+00:00

I am trying to set up a callback in jQuery that correctly binds this

  • 0

I am trying to set up a callback in jQuery that correctly binds “this” to the calling object. Specifically, here is the code I am working with. I am doing an ajax call in a Object like this:

Object.prototype.doAjaxCall = function(url)
    {
        $.get(url, null, this.handleAjaxResponse );
    }

However, in Object.prototype.doAjaxCall, this does not refer to the correct thing. I have worked with Prototype before and I know you need to bind this when you do the Ajax call, but I can’t seem the find the correct way to do that in jQuery. Can someone point me in the right direction?

  • 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-12T07:25:37+00:00Added an answer on May 12, 2026 at 7:25 am

    A more robust, native bind function should be part of ECMAScript 3.1. In the meantime…

    Object.prototype.doAjaxCall = function(url) {
        var bind = function(context, method) {
            return function() {
                return method.apply(context, arguments);
            };
        };
    
        $.get(url, null, bind(this, this.handleAjaxResponse));
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a jQuery plugin and I'm trying to set up a callback that
For the last few hours I've been trying to set up this http://code.google.com/apis/books/docs/dynamic-links.html on
I'm trying to set up an object so that it has an encapsulated $.getJSON
I'm trying to set a callback function in Jack. This is usually quite simple,
I am trying to set a global GetMessage hook on all threads. This is
I'm trying to set up a JSON query for PhoneGap that pulls in JSONP
I'm trying to build a jQuery.live like function. Helper is a class that has
I'm using jsdom with jquery, and it's working just fine. However, I'm trying to
This may be more of a scoping question. I'm trying to set a JSON
I'm trying to learn jQuery and it occurred to me that existing JS in

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.