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

  • Home
  • SEARCH
  • 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 7895535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T07:40:01+00:00 2026-06-03T07:40:01+00:00

How do I destroy instance variable after completing one ajax call. In my app

  • 0

How do I destroy instance variable after completing one ajax call. In my app data is returned via ajax and often new calls are made, some values from previous call are returned mixed with some new values. Is that something considered design flow? Or shall just move head by finding a way to destroy the veritable/values?

Example controller –

    def something
    @result = Stuff.find_all_by_requestor_name
    respond_to do |format|
    format.html { render :partial => 'list'}
    format.js
    end
    return @result 
    end

I have noticed few times that ajax requests mix up values. Am I mistaking big here?

  • 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-03T07:40:03+00:00Added an answer on June 3, 2026 at 7:40 am

    As far as your questions is concerned, There is no way for the instance variables to survive between calls, each http-call is independent of the other calls and variables don’t live till the next call. But I have noticed something weird in your code below

    def something
        @result = Stuff.find_all_by_requestor_name
        respond_to do |format|
            format.html { render :partial => 'list'}
            format.js
        end
        return @result 
    end
    

    Looking at this code above, I don’t see why are you returning a value from a controller function that gets an AJAX request. I think what you wanted to was the follwing

    def something
        @result = Stuff.find_all_by_requestor_name
        respond_to do |format|
            format.html { render :partial => 'list'}
            format.js { render :json => @result }
        end
    end
    

    you should render inside the format.js block rather than returning in the end. Hope that helps

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

Sidebar

Related Questions

I'v created a window after creating my main one but calling DestroyWindow on its
For debugging reasons I want to destroy a class instance which still as references.
In Ruby, can one object destroy another? For example: class Creature def initialize @energy
I have a machine running a java app talking to a mysql instance running
By using a singleton, only one instance of it can be created. Do we
I have an after_destroy model callback that regenerates cache after the model instance has
Do I have to destroy instances myself? ...if I don't assign them a variable...will
We need to create & destroy instances of QApplication, as we want to use
How to destroy the session on closing the browser When browser window is closed,
I want to destroy all i-frames of a video. Doing this I want to

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.