Is this possible

Hello again

I have a scenario where I am going to have a div that periodically
updates information from the server (think like a newsfeed or stock
ticker). I am using AJax on the browser side to accomplish this now.
However, I am wondering if it is possible for when the update request
comes in to the server If it is determined that the content hasn’t
changed to send back an “abort update” somehow to the browser that would
cause the div to remain unchanged. I am fairly new to the Prototype
classes in general so I am not even sure where to begin with this.

Ben

Hi Ben,

Darushin wrote:

I have a scenario where I am going to have a div that periodically
updates information from the server (think like a newsfeed or stock
ticker). I am using AJax on the browser side to accomplish this now.
However, I am wondering if it is possible for when the update request
comes in to the server If it is determined that the content hasn’t
changed to send back an “abort update” somehow to the browser that would
cause the div to remain unchanged. I am fairly new to the Prototype
classes in general so I am not even sure where to begin with this.

In your RJS template, or in the controller if that’s where you’re
currently
doing the render,

page.render :nothing => true

will accomplish what you’re looking for.

hth,
Bill

If you’re using an RJS template to return JavaScript to the browser
couldn’t you just return an empty response so that your page doesn’t
update.

What happens if you do something like this in your RJS template:

page.replace_html(“cart”, :partial => “cart”, :object => @cart) if
@cart.has_changes?

Of course you would need to provide the has_changes? method on your
object.

I can’t guarantee this will work because I’ve not tested this. But,
give it a shot and see what happens.