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.
6b46f4eed76df33a3ffacf87bc9f1079?d=identicon&s=25 vimal (Guest)
on 2009-04-28 09: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
Bee69cfed999cd13e3bff73d472a39ee?d=identicon&s=25 Hassan Schroeder (Guest)
on 2009-04-28 17:13
(Received via mailing list)
On Tue, Apr 28, 2009 at 12:31 AM, vimal <cool.vimalsmail@gmail.com>
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 Schroeder ------------------------ hassan.schroeder@gmail.com
This topic is locked and can not be replied to.