Forum: Ruby on Rails How to refresh Image through ajax request

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
047c2e2a6349db15db769e3ad46cf936?d=identicon&s=25 Kumar Saurav (sauravsuman012)
on 2009-01-17 08:33
Hi all ,
I am very new for ruby. I am using Ajax Request(Rmagick in controller)
for changing image on my DIV but the problem is it refresh for first
time only then after i have to refresh the browser always. If anybody
having any solution, Please let me know . I am posting my code here

Code in rhtml file
==================================================================================
<%= form_remote_tag({:url=>{:controller=>'image_builders', :action
=>'index'}, :update =>'photo'})%>
        <dl style="width:450px">
          <dt>Type</dt>
<!--  form element -->


</dl>
          <%= submit_tag 'Create Image' %>
        </div>

<!--  End of form -->
<!--  Preview Area  -->
<div>
          <label><b>Image:</b></label>

          <div id="photo" style="width:99%;">

          </div>
          </div>

<!--  End of Preview Area -->

===============================================================================
code in controller

 def index
    @Rows =20
    @Cols = 120
    @alpha = params[:alpha].to_i
    @margin = params[:margin].to_i
    if params[:height].to_i >9000 ||  params[:width].to_i  > 9000
      if params[:height].to_i >9000
        params[:height] = 8999
      end
      if params[:width].to_i  > 9000
        params[:width] = 8999
      end
    end
    if params[:height] && params[:width]
      @Rows =params[:height].to_i
      @Cols = params[:width].to_i
    end
      @Start = params[:input_field_1]
      @End = params[:input_field_2]
    if params[:type] == 'gradation'
      fill = Magick::GradientFill.new(0, 0, 0, @Cols, @Start, @End)
      img = Magick::Image.new(@Rows, @Cols, fill)
       img.opacity = @alpha/ 127.0 * Magick::TransparentOpacity if
@alpha != 0
      img_new = img.rotate(90)
      if params[:reverse]
        img_rev = img_new.rotate(270)
        img_rev.write("public/images/xyz.jpg")
        render :text => "<img src='/images/xyz.jpg' />"
      else
        img_new.write("public/images/xyz.jpg")
        render :text => "<img src='/images/xyz.jpg' />"
      end
    end
end
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-01-17 12:21
(Received via mailing list)
On 17 Jan 2009, at 07:33, Kumar Saurav wrote:

>
> Hi all ,
> I am very new for ruby. I am using Ajax Request(Rmagick in controller)
> for changing image on my DIV but the problem is it refresh for first
> time only then after i have to refresh the browser always. If anybody
> having any solution, Please let me know . I am posting my code here
>
Is it your browser caching the image?

Fred
This topic is locked and can not be replied to.