Rendering images through JS in rails

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:

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

On Tue, Apr 28, 2009 at 12:31 AM, vimal [email protected]
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. ------------------------ [email protected]