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?
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
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
you should
renderinside theformat.jsblock rather than returning in the end. Hope that helps