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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:42:22+00:00 2026-06-13T11:42:22+00:00

I have a somewhat annoying issue when it comes to sending an Ajax request

  • 0

I have a somewhat annoying issue when it comes to sending an Ajax request to a server and then returning the data on the success function within an JavaScript object. I’ve searched for similar questions, but none were really of the same manner as mine.

For example, I have the following code for sending a request within an object:

function SomeObject ( someVar )
{
    var someVar = someVar;
}

SomeObject.prototype.sendRequest = function ()
{
    $.ajax(
    {
        url  : "somePage.php",
        type : "POST",
        data :
        {
            someVar : someVar
        },
        success : this.parseSuccess
    } );
};

SomeObject.prototype.parseSuccess = function ( data )
{
    if ( data === "success" )
    {
        this.proceed();  // Error
    }
    else
    {
        alert( "Server failed request." );
        this.proceed();
    }
};

SomeObject.prototype.proceed = function ()
{
    // Do something else
};

I know that this.proceed() will fail because this is not the SomeObject instance.

Still, how can I efficiently refer back to the object after the request is complete?
I found I could do the following to achieve what I want, but it does not feel proper, and I would like a better way to handle the Ajax calls:

SomeObject.prototype.sendRequest = function ()
{
    var me = this;

    $.ajax(
    {
        url  : "somePage.php",
        type : "POST",
        data :
        {
            someVar : someVar
        },
        success : function ( data )
        {
            me.parseSuccess( data );  // Will work
        }
    } );
};

Thanks for any help on the matter.

  • 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-13T11:42:23+00:00Added an answer on June 13, 2026 at 11:42 am

    You can use the context option of $.ajax. Specifically, using context: this will set the this value inside parseSuccess to the current this value, which is what you want.

    $.ajax({
      // ...
      context: this,
      success: this.parseSuccess
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

UPDATE: I have somewhat resolved the issue. Just in case if anyone runs in
I have a somewhat strange issue with visual studio. Almost every time I create
I have a somewhat simple Client/Server solution running over C# remoting (System.Runtime.Remoting). The MarshalByRef
I have a somewhat long-running post-build event (long enough to be annoying to wait
I have somewhat interesting development situation. The client and deployment server are inside a
I have somewhat of a complex issue involving several different programs including redmine, MySQL,
I have come across a somewhat annoying problem during a project. I created this
I have somewhat of a thought question regarding jQuery Ajax. My question is this:
I have somewhat similar issue as this my VS 2010 does not hangup anymore
I need to extract a value from a hidden HTML field, have somewhat figured

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.