Forum: Ruby on Rails rendering images through JS in rails

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.
vimal (Guest)
on 2009-04-28 11:32
(Received via mailing list)
Hi,
    I am newbie to rails.
    I use an jquery ajax function to get some json data
    and have to render an image according to the result.

say
----------------------------------------------------------------------
HTML:
           <div id="status"></div>
----------------------------------------------------------------------
JS:
           if (true){
              $('#status').html(<%=IMAGE1%>);
           }
           else{
              $('#status').html(<%=IMAGE2%>);
           }
-----------------------------------------------------------------------

I've tried a lot of way but couldn't come to a solution.
Please help.

Regards,
Vimal Das
Hassan S. (Guest)
on 2009-04-28 19:13
(Received via mailing list)
On Tue, Apr 28, 2009 at 12:31 AM, vimal <removed_email_address@domain.invalid>
wrote:

>    I use an jquery ajax function to get some json data
>    and have to render an image according to the result.

Not really a Rails question, but...

> JS:
>           if (true){
>              $('#status').html(<%=IMAGE1%>);
>           }
>           else{
>              $('#status').html(<%=IMAGE2%>);
>           }

? Why don't you just return the appropriate image tag in your JSON
response, and insert it, e.g.  $('#status').html(new_image_tag ?

--
Hassan S. ------------------------ removed_email_address@domain.invalid
This topic is locked and can not be replied to.