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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:04:34+00:00 2026-05-11T00:04:34+00:00

My page deals with many Store objects, each of them has a field called

  • 0

My page deals with many ‘Store’ objects, each of them has a field called ‘data’. However, this data is fetched via AJAX requests which may be parallely going on.

function Store(id){     this.id = id;     this.queryparam = 'blah';     this.items = null; }  Store.prototype.fetch = function(){     $.get('/get_items',{q:this.quaryparam},function(data,status){        // how to store the received data in this particular store object? Being       // a callback function, I don't have a reference to this object as 'this'         // this.data = data; //will not work     }); } 

In the callback function I tried defining a default parameter to the calling objects as following:

$.get('/get_items',{q:this.quaryparam},function(data,status, ref = this) ... 

But turns out that javascript does not support default argument values like this. Can I somehow get jquery to pass a reference to ‘this’ store in the callback function?

I thought of a couple of other approaches but none of them work:

I could set the store data using synchronous requests but then thats not the point of AJAX, is it?

Another way for me could be, to send the store id also in the requests which will come back in the response. For eg:

// in Store.fetch() $.get('/get_items',{q:this.quaryparam,id:this.id},function(responsetext,status){     var response = eval(responsetext);     stores[response.id].data = response.data; }); 

I do not like this approach because this pollutes the response just because the client-side code was unable to keep track of which request was sent by which object.

Moreover, since store.id is client-specific, it will also mess up caching at the server. A different request URL will be used for two different stores even though they have the same query parameters.

Is there any other way to achieve what I want?

  • 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. 2026-05-11T00:04:34+00:00Added an answer on May 11, 2026 at 12:04 am

    You should be able to use closure:

    var tmp = this; $.get('/get_items',{q:this.quaryparam},function(data,status){     tmp.data = data; }); 

    Is that what you mean?

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

Sidebar

Ask A Question

Stats

  • Questions 74k
  • Answers 74k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Here are things to consider: Is this big project? If… May 11, 2026 at 2:15 pm
  • added an answer Have you tried the load event? This should be called,… May 11, 2026 at 2:15 pm
  • added an answer import sys def get_caller(ext=False): ''' Get the caller of the… May 11, 2026 at 2:15 pm

Related Questions

Inside my page, I have the following: <aspe:UpdatePanel runat=server ID=updatePanel> <ContentTemplate> <local:KeywordSelector runat=server ID=ksKeywords
On my page I have a drop-down select box, with a default value of
Help me ..my page index is not working in visual studio. my page load
I have forms in my page a get and a post and i want
A hobby project of mine is a Java web application. It's a simple web
I've read the manual many times, I've scoured the posts offered by Google on
My dad called me today and said people going to his website were getting
Like many others on this site I am considering a move to ASP.NET MVC

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.