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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:44:15+00:00 2026-05-21T05:44:15+00:00

my AJAX funciton doesn’t quite to work as I expect. It appears that this

  • 0

my AJAX funciton doesn’t quite to work as I expect.

It appears that “this” inside the AJAX success callback doesn’t refer to the same “this” as within the scope of the showSnapshotComment function.

I’ve tried using context it is still not working. My usage is probably incorrect. I am probably overthinking it.

    function showSnapshotComments(snapshot) {
    var self = $j(this);
    alert($j(this).attr('class'));
    $j.ajax({
    cache: false,
    context: this,
    url: 'show_snapshot_comments/' + snapshot.id,
        async: true,
    dataType: 'script',
    success: function() {
    $j('#snapshots a.photo').each(function(i) {
        $j(this).qtip({
        content: $j(this).nextAll('.info').eq(i),
        position: {
          target: 'mouse',
          adjust: { mouse: true },
                viewport: $j(window)
          },
        hide: {
            event: 'click mouseleave',
            delay: 300
        },
        show: {
            solo: true,
            event: 'click mouseenter'
        },
        style: {
            tip: true,
            classes: "ui-tooltip-light"
        }
    });
});

    }
  }); 
}
  • 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-21T05:44:15+00:00Added an answer on May 21, 2026 at 5:44 am

    Change your reference to self to be a DOM element instead of a jquery object (self = this) and in the success callback function change your this references to self.

    To understand why you need to do this you should read up on closures and closure scope:

    http://robertnyman.com/2008/10/09/explaining-javascript-scope-and-closures/

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

Sidebar

Related Questions

I execute an ajax function that takes 3 seconds + so in this time
I have a jQuery ajax function that retrieves JSON data. In the success block
i have a success function that has some data stored inside it: function(receiverUserIds) {
I have this configuration in struts.xml <action name=updateAction class=it.myApp.action.ajax.UpdateActionAction> <result name=success type=json/> <result name=error
I have a small JS function that does Ajax for me and another like
I have a jquery-ajax function that sends data to a php script and the
I have an AJAX function inside a javascript file and I want it to
$.ajax({ type: POST, url: OMFG.php, data: info, success: function(){ }}); is what I'm using
I'm writing an AJAX function that returns some information to display in a <div>
I'm using a wrapper function around jQuery's AJAX function like this: $.getAjax = function(url,

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.